VBA Help: If A Cell Is Blank Error; Otherwise No Error (part of a validation macro)

milwphil

Board Regular
Joined
Aug 1, 2010
Messages
120
Good afternoon/morning (wherever you might be in the world)!

I inherited a spreadsheet and I'm trying to keep the methodology consistent with how it was already built.

The author of the spreadsheet used a macro that provides a warning messages to users if they validate the spreadsheet and it's missing (or has incorrect information) to highlight the cell yellow and provide a warning message.

All I want to do is provide a similar message, but I don't need all the data validation (format) built in.

For example, this is a macro he used to return an error or pass validation:
Code:
oRow.Cells(1, 8).Value = Validations.CleanNonStndChars(UCase(Trim(oRow.Cells(1, 8).Text)))
    If Not Validations.StateValidation(oRow.Cells(1, 8)) Then
     .tbOVR_Results = .tbOVR_Results & "Jurisdiction validation error: Row " & Str(oRow.Row) & " please check." + vbNewLine
     oRow.Cells(1, 8).Interior.ColorIndex = 6
     oRow.Cells(1, 8).AddComment ("The State must be within the United States.")
    End If

I just need to be able to say, if there is any data in the field....no error, but if not error. It's probably so simple, I'm missing it...but regardless I'm still missing it.

Code:
[COLOR=red]If the cell has text "End If". If it's blank "Then":  [/COLOR]
tbOVR_Results = .tbOVR_Results & "License error: Row " & Str(oRow.Row) & " please check." + vbNewLine
oRow.Cells(1, 8).Interior.ColorIndex = 6
     oRow.Cells(1, 8).AddComment ("License information Required.")
End If

I'll be the first to admit....I'm not exactly sure I should be messing around with this thing called Excel VBA.

ANY HELP WOULD BE GREATLY APPRECIATED!
 
Last edited:

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
GOT IT! Writing it out helped....

This is what I came up with, which seems to work (for now)
Code:
If oRow.Cells(1, 9).Value = "" Then
 .tbOVR_Results = .tbOVR_Results & "License error: Row " & Str(oRow.Row) & " please check." + vbNewLine
     oRow.Cells(1, 9).Interior.ColorIndex = 6
     oRow.Cells(1, 9).AddComment ("License Number is required.")
     Else
     
     End If
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,242
Members
452,898
Latest member
Capolavoro009

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