ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Conditional Macro (https://www.excelbanter.com/excel-worksheet-functions/11009-conditional-macro.html)

Shelley Shepherd via OfficeKB.com

Conditional Macro
 
I have an Excel workbook which naviagates from sheet to sheet using a
control button to move to the next sheet in the workbook. How can I
program the macro attached to the control button so that if condition X
(False) is met, one moves to sheet A ("Insulin Rate"), but if condition Y
(True) is met, one moves to sheet B ("Prev Gluc 2")? This is what I've
tried thus far:
If ("G1") = False Then
Sheets("Insulin Rate").Activate
Range ("C3").Activate
ElseIf ("G1") = True Then
Sheets("Prev Gluc 2").Activate
Range ("C3").Activate
EndIf

I've also tried using .Select instead of .Activate, but that doesn't work
either. Appreciate your help.

--
Message posted via http://www.officekb.com

Bob Phillips

If Range("G1").Value = False Then
Sheets("Insulin Rate").Activate
Range ("C3").Activate
ElseIf Range("G1").Value = True Then
Sheets("Prev Gluc 2").Activate
Range ("C3").Activate
EndIf



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Shelley Shepherd via OfficeKB.com" wrote in message
...
I have an Excel workbook which naviagates from sheet to sheet using a
control button to move to the next sheet in the workbook. How can I
program the macro attached to the control button so that if condition X
(False) is met, one moves to sheet A ("Insulin Rate"), but if condition Y
(True) is met, one moves to sheet B ("Prev Gluc 2")? This is what I've
tried thus far:
If ("G1") = False Then
Sheets("Insulin Rate").Activate
Range ("C3").Activate
ElseIf ("G1") = True Then
Sheets("Prev Gluc 2").Activate
Range ("C3").Activate
EndIf

I've also tried using .Select instead of .Activate, but that doesn't work
either. Appreciate your help.

--
Message posted via http://www.officekb.com





All times are GMT +1. The time now is 06:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com