Thread: Column location
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
CBrine[_5_] CBrine[_5_] is offline
external usenet poster
 
Posts: 9
Default Column location

Sub FindColumn()
Dim cell As Range, FoundColumn As String
For Each cell In ActiveSheet.Range("A1",
ActiveSheet.Range("IV1").End(xlToLeft))
If lower(cell) = "mad" Then
FoundColumn = cell.Column
MsgBox FoundColumn
End If
Next cell

End Sub

I've made the test case insensitive using lower, if you want it case
sensitive then remove the lower method.

HTH
Cal


" wrote:

Hi

How do I search the columns for a specific column name so I can
reference that column number in future code?

for ex:

happy sad mad laugh

I need to know that mad is column 4.



Thanks