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,210
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

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
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,224,890
Messages
6,181,612
Members
453,057
Latest member
LE102024

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