PDA

View Full Version : Solved: Check Cell Contents In A Column



tonyrosen
12-19-2005, 02:37 PM
Here's what I'm TRYING to figure out.

Let's assume that you "Select" column B ...

How would I go about checking each cell in Column B?

For Each Cell in Range("B:B")
iData = Value.Cell
If Len(iData) < 4 Then
'Do this
End If
Next


Obviously, this gives me EVERY cell, but I only need to check the ones with data in them.

mdmackillop
12-19-2005, 03:16 PM
This will find all formulas and constants in column B, ignoring the blanks.

Sub Macro1()
Dim MyRange As Range, Cel As Range
Set MyRange = Union(Columns(2).SpecialCells(xlCellTypeConstants, 23), _
Columns(2).SpecialCells(xlCellTypeFormulas, 23))
MyRange.Select
For Each Cel In MyRange
DoEvents
Next
End Sub

tonyrosen
12-20-2005, 09:36 AM
After tinkering with this this morning, I came up with a solution which does the trick, but is mostly useless (as is the sheet itself anyway).

Thanks!