XLOOKUP not working correctly in macro

Kekda

New Member
Joined
Sep 6, 2022
Messages
15
Office Version
  1. 2021
Platform
  1. Windows
Hello!
I'm trying to create a table of data on several products which I will be updating with a new column to the right on a monthly basis. See link: sample.xlsx

To make this easier I've tried to record a simple macro which pulls data from another sheet and puts the data in position for me to review. The steps go as follows:

1. Right click table, enter new column to right
2. In the new 'F' column I have created I enter my xlookup formula which pulls data across nicely, for month September
3. Change rounding up/down as necessary
Then I stop recording and after deleting the data just entered, I run the macro and it works nicely, entering everything I just recorded. However when I run it again straightaway, it creates a new column but the xlookup formula is still stuck in the 'F' column, and so it just recopies the data for September on top. What I'm after is an xlookup formula that shifts over to the new column I've created so I have static data for each month lined up in columns.

Hope this makes sense.
Thanks in advance
 
Thank you, that works perfectly.

I also have a sparkline which I would like to update as per table not absolute columns. Any way to make this work?
 
Upvote 0

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
I also have a sparkline which I would like to update as per table not absolute columns. Any way to make this work?
That is an entirely different question that needs its own thread (besides which, I have NEVER worked with Sparklines, so I know absolutely nothing about them).
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,194
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top