ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Count macro (https://www.excelbanter.com/excel-discussion-misc-queries/236190-count-macro.html)

nbhp

Count macro
 
I have 2 columns of data (A3:A100 and H3:H100) and wish to count the number
of non-blank cells in each range, then compare the totals. If the totals are
equal then the tab for the worksheet will change colour, say red. I have not
really used the count function before and all attempts so far have failed.

Anyones help would be greatly appreciated.

Many Thanks

Jacob Skaria

Count macro
 
Try the below macro which works on the activesheet

Sub CountBlanksColorTab()
If WorksheetFunction.CountBlank(Range("A3:A100")) = _
WorksheetFunction.CountBlank(Range("H3:H100")) Then
ActiveSheet.Tab.ColorIndex = 3
Else
ActiveSheet.Tab.ColorIndex = -4142
End If
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"nbhp" wrote:

I have 2 columns of data (A3:A100 and H3:H100) and wish to count the number
of non-blank cells in each range, then compare the totals. If the totals are
equal then the tab for the worksheet will change colour, say red. I have not
really used the count function before and all attempts so far have failed.

Anyones help would be greatly appreciated.

Many Thanks


Bob Phillips[_3_]

Count macro
 
If Application.Counta(Range("A3:A100")) =
Application.Counta(Range("H3:H100")) Then

Activesheet.Tab.Colorindex = 3
End If

--
__________________________________
HTH

Bob

"nbhp" wrote in message
...
I have 2 columns of data (A3:A100 and H3:H100) and wish to count the number
of non-blank cells in each range, then compare the totals. If the totals
are
equal then the tab for the worksheet will change colour, say red. I have
not
really used the count function before and all attempts so far have failed.

Anyones help would be greatly appreciated.

Many Thanks





All times are GMT +1. The time now is 12:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com