I have a macro that opens another worksheet and pulls information via VLOOKUP formulas from a range that I name within that sheet. Recently, for some reason the information has been showing up in different columns on the report and since I can't control how that report is produced, I need to be able to find a certain text string that will indicate the top left cell of my range. Then I can search for another text string on that same row to get the width of my range. Previously when the reports were consistently being produced I had the macro count the number of rows with text in the starting column of the range to determine the height of my range. Since the starting column is moving around, it sometimes resides in the same column as the header information, so I can't predict how many rows of text to exclude from my COUNTA calculation.
What I need is a macro that will create a named range, the size of which we will determine. First it will search for the phrase "SS Acct #"; this will be the top left cell of the range. I believe if we limit the possible range of finding that phrase to cells B10:E20 that will provide more than enough room to handle the inconsistency of this report. From that cell we need to count how many rows below it have text in them. That number will be the number of rows in our range. We will also search for "Amount" in the same row as we found SS Acct #. That will represent the last column in our range and will be the column we use in our VLOOKUP formula as the amount to return.
I've been able to find the top left cell. I'm not sure how to count the rows beneath that cell that have been used. The amount column has consistently been two columns over from the 1st column, but I don't want to assume that will remain. I'm having the most trouble converting row numbers into ranges and now I think I'm so lost in the weeds there must be a easier solution, that hopefully one of you will share.
An example of the data would be as follows:
C D E
12: SS Acct # Amount
13: ABF2 93,402.97
14: ABF5 5,643.07
The next time this report comes C12 might be D12 and E12 would now be F12.
Thanks in advance for any help.
What I need is a macro that will create a named range, the size of which we will determine. First it will search for the phrase "SS Acct #"; this will be the top left cell of the range. I believe if we limit the possible range of finding that phrase to cells B10:E20 that will provide more than enough room to handle the inconsistency of this report. From that cell we need to count how many rows below it have text in them. That number will be the number of rows in our range. We will also search for "Amount" in the same row as we found SS Acct #. That will represent the last column in our range and will be the column we use in our VLOOKUP formula as the amount to return.
I've been able to find the top left cell. I'm not sure how to count the rows beneath that cell that have been used. The amount column has consistently been two columns over from the 1st column, but I don't want to assume that will remain. I'm having the most trouble converting row numbers into ranges and now I think I'm so lost in the weeds there must be a easier solution, that hopefully one of you will share.
An example of the data would be as follows:
C D E
12: SS Acct # Amount
13: ABF2 93,402.97
14: ABF5 5,643.07
The next time this report comes C12 might be D12 and E12 would now be F12.
Thanks in advance for any help.