Hello,
I am just beginning to learn Excel macros. I was working on a sheet wherein I have to select a column dynamically, based on just the column header name. Let me explain.
Say there is an Excel Sheet which contains the following columns (from A1 to D1):
RecNo Cust_ID Cust_Name Contact_Num
Below these, there is customer data which is present. Now, I want to extract just the Cust_ID (from Column B) and Cust_Name (from Column C) for all the records.
However, the problem is that it is not necessary that Cust_ID would always be in Column B. Though the heading would always be Cust_ID, its location could change to Column C in some other sheet that has been generated and Cust_Name could instead have been present in Column B (the two columns that need to be extracted have been interchanged).
Using the match function, I am able to determine the position of the column, but after that I am not able to select that column. The function I have used to determine the column number is given below:
WorksheetFunction.Match("Cust_ID", Range("A1:D1"), 0)
Can someone please help?
Configuration: Windows XP Internet Explorer 7.0