Set rColCells = Selection.Cells(1.1)
• Resizes the selection to only the top left cell
Set rColCells = Range(rColCells, rColCells.End(Direction:=xlDown))
• Expands that selection down to the last non-blank cell
G_Count = G_Count - (InStr(1, UCase(cCell.Value), "G") > 0)
• Increments G_Count by the value returned from:
(InStr(1, UCase(cCell.Value), "G") > 0)
• The InStr function returns the position of the found text...Zero if the text is not found.
• We want to know if the position is greater than 0.
• In VBA, TRUE = -1...so we need to subtract the returned value to INCREASE the count. (FALSE = 0)
As the code progresses down the column of cells, each "hit" of a letter increases the count for that letter.
Does that help?
Bookmarks