View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
lykwid[_3_] lykwid[_3_] is offline
external usenet poster
 
Posts: 1
Default Select.Range function in VB IF statements?

Hi,

Private Sub ActivityBrowserButton_Click()

If Range("B6").Value = 1 Then
Sheets("Aerobics").Select

ElseIf Range("B6").Value = 2 Then
Sheets("Aqua").Select
____________________

ElseIf Range("B6").Value = 16 Then
Sheets("Yoga").Select

Else
End If

End Sub

The above code is what I am using for my form. The straight line just
indicates more or less repeat code.

The form looks in cell B6 for a value, and if the value is between 1-16
it will go to the shee I have defined for it. IE, IF B6=1 .. open
"Aerobics".

This part of the form works fine, however I can't select a cell for the
form to go to when it loads the sheet. Could anyone suggest any methods
how to do this?

I've tried:

If Range("B6").Value = 1 Then
Sheets("Aerobics").Select
Range("A6").Select
------------- And I got "Select method of range class failed"

I have also tried:

If Range("B6").Value = 1 Then
Sheets("Aerobics").Range("A6").Select
------------- And I got the exact same error.

If anyone could help I would be very grateful.

Thanks.


---
Message posted from http://www.ExcelForum.com/