-
From what I think you're trying to do, try this and see if it does what you want...
In any standard code module (up the top)[vba]
Option Explicit
Public OK As Boolean
[/vba]
In the ThisWorkbook code module[vba]
Option Explicit
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
If OK Then
With Sh
.Cells.Interior.ColorIndex = xlNone
Union(.Range("A" & Target.Row, Target), _
.Range(Cells(7, Target.Column), Target)) _
.Interior.ColorIndex = 6
End With
End If
End Sub
[/vba]
In the UserForm code module[vba]
Option Explicit
Private Sub cmdOK_Click()
OK = True
'....some code.... 'open worksheet
'....some code.... 'worksheet now open is the active worksheet
End Sub
Private Sub UserForm_Terminate()
OK = False
End Sub
[/vba]
You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you
The major part of getting the right answer lies in asking the right question...
Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules