View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default 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/