ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If statement in Auto_Open (https://www.excelbanter.com/excel-programming/296669-if-statement-auto_open.html)

Ian M

If statement in Auto_Open
 
When an Excel Workbook opens, if cell A1 in Sheet1 contains nothing I
want Excel to run Macro1.

If cell A1 in Sheet1 contains the text "Hello", I want Excel to do
nothing.

I've tried this:

If (Sheet1)A:1 = "Hello"
Then
Range("A1").Select
Else
Macro1
End If

but VB gives me the red pen for the first two lines.

Any ideas?

Kind regards

Ian M

Chris

If statement in Auto_Open
 

If Sheets("Sheet1").Range("A1") = "Hello" The
Range("A1").Selec
Els
Macro
End I

----- Ian M wrote: ----

When an Excel Workbook opens, if cell A1 in Sheet1 contains nothing
want Excel to run Macro1

If cell A1 in Sheet1 contains the text "Hello", I want Excel to d
nothing

I've tried this

If (Sheet1)A:1 = "Hello
The
Range("A1").Selec
Els
Macro
End I

but VB gives me the red pen for the first two lines

Any ideas

Kind regard

Ian


Ian M[_2_]

If statement in Auto_Open
 
Chris

It works perfectly!

Thanks again for your help.

Kind regards

Ian M



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 09:54 AM.

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