A Macro to warn me if one cell in a row has data but another does not?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
I have a sheet that is called "Deadlines"

I input data in the following ranges

F7:F150
H7:H150
I7:I150

Now people keep missing one or the other of these inputs,
so can I have a macro that when run checks and if any cell in any row has data then every cell in that row must have data otherwise Messagebox "You Can Not Proceed"

please help if you can

Thanks

Tony
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Lazy way....

Code:
Sub TomWatson()
    If WorksheetFunction.CountA(Range("F7:F150")) <> 144 Or _
       WorksheetFunction.CountA(Range("H7:H150")) <> 144 Or _
       WorksheetFunction.CountA(Range("I7:I150")) <> 144 Then MsgBox "You Can Not Proceed"
End Sub

Although you probably want to put it in a worksheet event but you haven't stated how you are triggering it.
 
Upvote 0
Thank you Mark859
this is great,
I didn't need it in worksheet event as its already doing loads so just wantend to add it before
but everything is working exactly as i wanted so thank you :)
 
Upvote 0
You're welcome, btw you can shorten it to

Code:
Sub TomWatson()
    If WorksheetFunction.CountA(Range("F7:F150,H7:H150,I7:I150")) <> 432 Then MsgBox "You Can Not Proceed"
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,632
Messages
6,120,652
Members
448,975
Latest member
sweeberry

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top