Search for column header in Excel 2007

5 pts.
Tags:
Excel 2007
Excel 2007 functions
Excel 2007 macros
Excel functions
Excel macros
I use a macro for a weekly report. In the macro i use "Column ("C:C").Select to select that column to filter out the zeros. Sometimes the information is in a different column when the data is downloaded, but the header of the column is still the same: "90_day_Late". How do i search for "90_day_Late" (say it is now in column F) and tell excel what column it is in by add the script to the macro to filter this data no matter what column it is in. I tried the "Match" function, but returns a number, and don't know how to covert number to letters. Can someone help?

Software/Hardware used:
Excel 2007, xp, laptop

Answer Wiki

Thanks. We'll let you know when a new response is added.

You could use some code like this in your current macro:

<pre>Dim rHeader As Range
Set rHeader = Range(“a1:z5″).Find(“90_day_Late”)</pre>

and then change this line:

<pre>Column (“C:C”).Select</pre>

to:

<pre>rHeader.Select</pre>

In this example it will look for the desired header in range a1:z5. If it is outside that range it won’t find it.

If there is a chance that the header is not present, you should add some code to validate it, because in that case “rHeader.Select” would produce an error.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following