View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave O Dave O is offline
external usenet poster
 
Posts: 427
Default Creating worksheets from a database

Hi, Paul-
This is a snippet of code I wrote for another project that does the
same thing: land the cell pointer in a range that contains tab names,
then jump to that tab. Please note because of word wrapping on this
Usenet interface, some line breaks may need to be adjusted in the VBA
editor.

Sub Jump()
Dim GoToTab As String

'Validation: ensure the cell pointer is in the correct range
'Suppose your list of tabs occurs in cell A10 thru A20. Use this to
make sure the cellpointer
'is in the proper range. There are more elegant ways to do this if
the range will expand:
'for instance, use a Named Range that will expand as the selection
expands, then use additional
'validation to make sure the cell pointer is within the range. This
will work for now.
If ActiveCell.Column < 10 Or ActiveCell.Row < 10 Or ActiveCell.Row
20 Then
MsgBox "To jump to a tab, place the cell pointer on a tab inside the
valid range and then press the Jump button."
End
End If

GoToTab = ActiveCell.Value

'unhide the sheet, if it is hidden
Sheets(GoToTab).Visible = True

'go to tab
Sheets(GoToTab).Select
Range("a1").Select

End Sub

Dave O