Hi, can anyone provide me with the vba codes to highlight cells in column 'G' that contain the word NULL
I'm a beginner in VBA and programming so any help will be highly appreciated.
thank you in advance
Hi, can anyone provide me with the vba codes to highlight cells in column 'G' that contain the word NULL
I'm a beginner in VBA and programming so any help will be highly appreciated.
thank you in advance
Try:![]()
Sub FillCell() Application.ScreenUpdating = False Dim LastRow As Long LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row Dim rng As Range For Each rng In Range("G2:G" & LastRow) If rng = "NULL" Then rng.Interior.ColorIndex = 3 End If Next rng Application.ScreenUpdating = True End Sub
You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
Practice makes perfect. I'm very far from perfect so I'm still practising.
I'm new to but I think you can also use conditional formatting for this and use equal to
Tony, you are correct, however, it appears the OP wants a VB solution![]()
1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
2. If your question is resolved, mark it SOLVED using the thread tools
3. Click on the star if you think someone helped you
Regards
Ford
Hi,
here's another alternative elaborating with the evaluate function:
Otherwise, in addition to Mumps1's suggested approach, you could also use autofilter or the find+findnext function.![]()
Sub BerlanActivesheetProcedure() Range(Join(Filter(Evaluate(Replace("transpose(if(@=""NULL"",address(row(@),column(@)),""#""))", "@", Range("G1", Range("G" & Rows.Count).End(xlUp)).Address)), "#", 0), ",")).Interior.ColorIndex = 3 End Sub
Kind regards,
berlan
Last edited by berlan; 04-17-2015 at 05:12 PM.
↑ will give you error when the number of cells that contains "NULL" exceeds about 40
![]()
Sub test() Rows(1).Insert With Columns("g") .AutoFilter 1, "NULL" .Interior.Color = vbRed .AutoFilter End With Rows(1).Delete End Sub
This is amazing!! All of my sort code in workbooks now looks pristine and beautiful when it runs. This is why i read through all of these posts! Thanks :D![]()
Application.ScreenUpdating = False
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks