We help IT Professionals succeed at work.
Get Started

Excel VLookup in a macro where returned column changes every month

220 Views
Last Modified: 2017-04-18
I hope I can explain this clearly. I have an Excel file that shows YTD months and a total that I need to create a macro for to do some formatting, and a VLookup. I know how to do that. Problem is, the column # in the VLookup will change every month as the total column will get pushed over as a new month is added. I attached a mock up of the file, if you go to the SUGAR worksheet you will see the macro button. Running it now works fine because the VLookup is =VLOOKUP(B:B,Sheet1!C:H,5,FALSE) where column # 5 is the total column from the pivot table. Next month when April is added the total column # will be 6, and so on. Not sure how to control that in the macro. Hope this makes sense.
thx experts...
BobR
vlookup-question.xlsm
Comment
Watch Question
Analyst Assistant
CERTIFIED EXPERT
Distinguished Expert 2020
Commented:
This problem has been solved!
Unlock 2 Answers and 7 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE