Macro Help

jlowry

New Member
Joined
Jul 20, 2020
Messages
1
Office Version
  1. 365
Platform
  1. MacOS
Hi all,

I need help with an excel macro. I have only started to use macros and as a result have a very basic knowledge and understanding. I was wondering is it possible to create a macro that can be reused even when the raw data coming in changes the position of the cell that the macro was originally connected to, along with moving the desired data to the next column across along a table.

To give an example. The below screenshot displays the raw data and table worksheets. The current months data - highlighted in yellow, C8 and G8 - needs to moved to the next worksheet 'Table' under the current month and must correspond to the equivalent bread type. What I want the macro to do is to understand that: the next time I run the macro rather than taking the values from cells C8 and G8 and placing the values into I4 and I5 of worksheet 'Table' respectively. I want it to essentially create a recurring cycle of taking the next two values below and placing them in the next empty place along the table in the worksheet 'Table'.

I attempted to use offset but it means I would have to keep editing the macro to alter the desired location to take and place the data which defeats the purpose of what I am trying to achieve.

Sheet - Raw Data.jpg
Sheet - Table.jpg


I do not know if this is really simple and I'm just not getting it or whether it is relatively tricky. Eventually I hope to take these learnings to use this macro on a larger scale if possible but for now I just want to get the basics of it correct. I would really appreciate any help as I am only beginning to find my feet with macros. Thank you in advance.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
If it is always the last cells with data in column C & G then you can use
VBA Code:
Columns("C").Find("*", , xlValues, , xlByRows, xlPrevious).Copy
Columns("G").Find("*", , xlValues, , xlByRows, xlPrevious).Copy
 
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,141
Members
453,021
Latest member
Justyna P

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