-
Help - activate sheet
Hello,
Im trying to activate a sheet within the workbook based on the cell 'G6'
[vba]
Sheets(Sheets("control").Range("g6").Value).Activate
[/vba]
What am I doing wrong???
Example, if I have sheet names , yes, no , maybe, and the word maybe is in cell g6 , I would like the sheet 'maybe' to 'activate'
-
Please help! Im on a deadline and this is the only line holding me back! I will PAY someone!!
-
You must use an event!
[vba]
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Me.Range("a1").Value = "maybe" Then
Sheet3.Activate
End If
End Sub
[/vba]
You can leave the sheet that contains the code, then return after some other code on the destination sheet later.
-
?
The sheet names are already in place, lets say name 1 through 12, and its going between files. The data need to know which sheet to dump the data dynamically . So if I say 'sheet' maybe , the other 11 sheets are out of luck.
-
Wait ... your right. It will work , I'll just need to specify the other 11 ... its messy, but I'll take it @!! Thank you.
-
You can try...call the sheets by the user name sure!
[VBA]
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Me.Range("a1").Value = "Maybe" Then
Sheets("Maybe").Activate
ElseIf Me.Range("a1").Value = "No" Then
Sheets("No").Activate
ElseIf Me.Range("a1").Value = "Yes" Then
Sheets("Yes").Activate
End If
End Sub
[/VBA]
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