How to tell excel to run a macro when column headings become blank

billyheanue

Board Regular
Joined
Jul 13, 2015
Messages
109
Hi everyone,

I took a stab at making a macro that simply adds a column, copys adjacent cells formatting into it, and copies the adjacent cells column heading into the new one - but changes it slightly. For example, it changes the column heading "Case Price Effective 05.01.15" to "Case Price Effective 08.01.15".

However, I am working with excel sheets that vary in the amount of columns. While the macro works for one sheet, another sheet may have 1 or 2 fewer columns, and the absolute reference of the macro fails to work.

How do I tell excel to run the macro only for the cells to the RIGHT of the last column? For example, the macro would create the 2nd column, but only after seeing that "Case price effective 08.01.15" was the LAST column populated.:eek::confused:

Case price effective 08.01.15Case Price effective 11.01.15
$23.03

<tbody>
</tbody>
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,053
Latest member
Mesh

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