How to select a range based on what's in the row header?

  • Thread starter Thread starter Rachel Garrett
  • Start date Start date
R

Rachel Garrett

I would like my macro to look for the word "Date" and then create a
range called "Date_Column", rather than hard-coding it that Date will
always be column B, column D, etc. Any suggestions or pointers to
tutorials?

Thanks,
Rachel
 
Sub date_finder()
For Each r In ActiveSheet.UsedRange
If r.Value = "Date" Then
Set Date_Column = Columns(r.Column)
Exit For
End If
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top