Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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/

  #2   Report Post  
Posted to microsoft.public.excel.programming
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/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Select.Range function in VB IF statements?

Yay, it worked :)

Thanks soo much

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF Statements to Select Case??? Walter Excel Discussion (Misc queries) 2 December 2nd 09 08:00 PM
How can change range to select active rows instead of :=Range("S10 ldiaz Excel Discussion (Misc queries) 7 August 29th 08 03:52 PM
When entering data into a range of cells, select the entire range. Q Excel Discussion (Misc queries) 0 September 26th 07 04:36 AM
Combine Intersect Range in If statements Ben Dummar Excel Discussion (Misc queries) 5 March 22nd 07 10:37 PM
Excel MS Query multiple select statements Revenger Excel Discussion (Misc queries) 3 May 12th 06 12:32 PM


All times are GMT +1. The time now is 03:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"