Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi. Prior to a macro executing, I would like to have the code check a
certain condition. If Cell A1 is not blank, then B1 is a required field. So conceptually, look at the entire Sheet1, scan column A. For each cell in column A, if a cell is populated, then cell B should be too. If not, Msg Box (ideally detailing what cell triggered the Msg Box) and end the sub. I am thinking this is a separate Sub that will run prior to the main sub. It does not have to check the Sheet dynamically. I just can't have the Main Sub execute with missing info. Can anyone help? Thank you! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Use code like the following:
Dim Rng As Range For Each Rng In ActiveSheet.UsedRange.Columns(1).Cells If Rng.Value < "" Then If Rng(1, 2).Value = "" Then MsgBox "Blank cell in " & Rng(1, 2).Address Exit Sub End If End If Next Rng -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Steph" wrote in message ... Hi. Prior to a macro executing, I would like to have the code check a certain condition. If Cell A1 is not blank, then B1 is a required field. So conceptually, look at the entire Sheet1, scan column A. For each cell in column A, if a cell is populated, then cell B should be too. If not, Msg Box (ideally detailing what cell triggered the Msg Box) and end the sub. I am thinking this is a separate Sub that will run prior to the main sub. It does not have to check the Sheet dynamically. I just can't have the Main Sub execute with missing info. Can anyone help? Thank you! |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Chip!
"Chip Pearson" wrote in message ... Use code like the following: Dim Rng As Range For Each Rng In ActiveSheet.UsedRange.Columns(1).Cells If Rng.Value < "" Then If Rng(1, 2).Value = "" Then MsgBox "Blank cell in " & Rng(1, 2).Address Exit Sub End If End If Next Rng -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Steph" wrote in message ... Hi. Prior to a macro executing, I would like to have the code check a certain condition. If Cell A1 is not blank, then B1 is a required field. So conceptually, look at the entire Sheet1, scan column A. For each cell in column A, if a cell is populated, then cell B should be too. If not, Msg Box (ideally detailing what cell triggered the Msg Box) and end the sub. I am thinking this is a separate Sub that will run prior to the main sub. It does not have to check the Sheet dynamically. I just can't have the Main Sub execute with missing info. Can anyone help? Thank you! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|