PDA

View Full Version : Solved: Looping named cells



sconly
04-14-2010, 06:58 AM
I have a worksheet with some named cells, ie. cells a2, a3, a4 have been give the names INJ1, INJ2, INJ3.

Is it possible to loop through these cells to check that they have a value in them?

FYI, what i mean by saying i've named the cells is i've selected the cell and done 'Insert -> Name -> Define' from the menu bars.

Thanks!!

Bob Phillips
04-14-2010, 07:23 AM
Dim cell As Range

For Each cell In Range("INJ1,INJ2,INJ3")

Debug.Print cell.Address
Next cell

sconly
04-15-2010, 12:52 AM
Thanks for the reply xld. Is it possible to do a like/left function or do I have to put in the full cell name?

Bob Phillips
04-15-2010, 05:22 AM
Has to b e the full cell name I am afraid.

mdmackillop
04-15-2010, 09:25 AM
Sub CheckVals()
Dim Nm, Msg$
For Each Nm In ActiveWorkbook.Names
If Nm.Name Like "INJ*" Then
Msg = Msg & Nm.Name & vbTab & Range(Nm).Value & vbCr
End If
Next
MsgBox Msg
End Sub