Macro to cover entire workbook

Datatellsall2

New Member
Joined
Jul 17, 2018
Messages
23
Hi There,

I have the following macro to highlight cells which include 2 consecutive words that start with a capitalized letter. I would like for this macro to cover my entire workbook and not a specific range. Do I only need to change what is in red? Or is there more to it?

Sub HighlightCellsWithTwoOrMoreUpperCaseLetters()

Dim Cell As Range, DataRange As Range

Set DataRange = Range("A1:A100")

DataRange.ClearFormats

For Each Cell In DataRange

If Cell Like "*[A-Z]*[A-Z]*" Then Cell.Interior.Color = vbYellow

Next

End Sub


Thanks so much,
M
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
If you mean for it to work on the entire sheet, just change that line to
VBA Code:
Set DataRange = ActiveSheet.UsedRange
If you want it to work on all sheets, will it be the same range on each sheet?
 
Upvote 0
Thank you. That's helpful!

Do you know if there is a way to have a macro highlight fields that have two consecutive words with the first letter being capitalized? Right now this macro captures anything with two or more upper case letters.

I'm hoping this maro would catch something like:

I.e. Susan Smith
i.e. We went to the beach with Susan Smith

I assume in excel it's not possible to highlight the individual text, but that would be preferred. If not, highlighting the entire cell is fine.

Thanks again,
M
 
Upvote 0
It is possible to highlight individual words, but it tends to be slow, especially if you have a lot of data
 
Upvote 0

Forum statistics

Threads
1,214,884
Messages
6,122,082
Members
449,064
Latest member
MattDRT

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