Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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/ |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select.Range function in VB IF statements?
Try Sheets("Aerobics").Select Sheets("Aerobics").Range("A6").Select -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "lykwid " wrote in message ... 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/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select.Range function in VB IF statements?
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
IF Statements to Select Case??? | Excel Discussion (Misc queries) | |||
How can change range to select active rows instead of :=Range("S10 | Excel Discussion (Misc queries) | |||
When entering data into a range of cells, select the entire range. | Excel Discussion (Misc queries) | |||
Combine Intersect Range in If statements | Excel Discussion (Misc queries) | |||
Excel MS Query multiple select statements | Excel Discussion (Misc queries) |