View Full Version : If Statement Excel Macro
Bob789
05-11-2017, 02:43 PM
Through the use of an Excel macro If Statement, I want to be able to analyze the current cell position and depending on the cell position have the macro move the cursor. This is the statement that I wrote but does not seem to work. It skips to the end if and does not perform the command.
If ActiveCell = "$A$2" Then
'Application.Goto Reference:="R10C1"
End If
Leith Ross
05-11-2017, 03:08 PM
Hello Bob,
Try using A1 style references throughout your macro. You don't need Application.GoTo. You can move to a cell simply by selecting it.
If ActiveCell.Address = "$A$2" Then
Range("$A$10").Select
End IF
Bob789
05-11-2017, 03:17 PM
Leith,
Thank you so much. That worked great!
Leith Ross
05-11-2017, 03:30 PM
Hello Bob,
You're welcome.
Bob789
05-11-2017, 04:30 PM
Leith,
Can you tell me how to check for a blank cell. Sorry, this is my first attempt at Excel macros so I am a bit novus. Below is what I am trying but it is no working. Again it is skipping to the End If. Thank you
If ActiveCell.Address = "" Then
ActiveCell.FormulaR1C1 = "1"
End If
Bob789
05-11-2017, 04:45 PM
Leith,
I figured it out
Set rRng = Sheet1.Range("A3")
If IsEmpty(rRng.Value) Then
Leith Ross
05-11-2017, 05:11 PM
Hello Bob,
Good work for a novice.
Paul_Hossler
05-11-2017, 05:23 PM
Yea, that's the best way to learn
You can mark your question solved by using [Tread Tools] about your first post, and selection [Solved]
Bob789
05-11-2017, 06:22 PM
Thanks everyone. This is a fantastic website. Paul I will mark as solved through thread tools but I not sure how to do that. Thanks
Paul_Hossler
05-11-2017, 06:48 PM
19152
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.