Macro to check if a cell has been filled in if cell next to it is?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,210
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone

I need a macro to mack sure people are filling in both columns
what I need is if

any cells in Range AH52:AH252 have data in them then check that the same row for column AG has data, if not message box "please fill in all departments before proceeding!"

please help if you can

Tony
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
How/when would you like this macro to run?
Are they going to be calling it/running it manually, or would you like it to somehow be automated?
If automated, we need to know what should trigger it to run (when it should run).
 
Upvote 0
Hi Joe,
The macro runs when they press a button so normal macro is fine thanks
 
Upvote 0
Try this:
Code:
Sub MyCheckingMacro()

    Dim cell As Range
    Dim msg As String
    
    msg = "Missing entries from cells: "
    
    For Each cell In Range("AH52:AH252")
        If cell <> "" And cell.Offset(0, -1) = "" Then
            msg = msg & cell.Offset(0, -1).Address(0, 0) & ","
        End If
    Next cell
    
    If Len(msg) > 28 Then
        MsgBox Left(msg, Len(msg) - 1), vbOKOnly, "MISSING ENTRIES!"
    Else
        MsgBox "No missing entries", vbOKOnly, "DATA VERIFIED!"
    End If
    
End Sub
 
Upvote 0
Hi Joe,
Worked first time perfectly,
Took out the veriffied part but handy to have it there as I'm bound to use this again and again.

Thanks

Tony
 
Upvote 0

Forum statistics

Threads
1,223,723
Messages
6,174,107
Members
452,544
Latest member
aush

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