Forum Discussion
Newbie trying to use Macros to delete/add columns
Hi @Moss Levenso
From above i have some doubts, clarify them, i definitely solve your problem.
1. As per your screenshot, you have sheet which always showing 12 months figures. right?
2. Above sheet has report from Apr 17 to Mar 18 (12 months). Next month will you delete Apr-17, and Add Apr-18 values. right?
If both of the above is right means, i can write macro. Please specify the cell reference (i.e) from which column and row value starts.
- Moss LevensonApr 13, 2018Copper Contributor
Thanks for your reply. The answer to both of your questions is Yes. But I think I actually figured it out on my own yesterday. I used the Macro recorder and performed the steps I wanted to create the macro. It certainly took a few attempts to get it right. The only question I have now is: do you know if the macro recorder will write macro for specific cell references or relative to where your cursor is?? Example? If I delete column N and add a column to the left of column C, will the macro do exactly that when it is run? Or does it depend on where my cursor is. Say I had a certain cell selected when I recorded the macro. Will the macro delete and add a column relative to where that cell is? Do I need to watch what cell is selected when I execute the macro?? Thank you so much, Moss
- Logaraj SekarApr 13, 2018Iron Contributor
Hi
I always do it for specific cell reference only. Will not write relative to cursor. So don't worry.
Before running macro, make sure that excel file and excel sheet.
Because, recording macro will blindly record active sheet. So it will run on any excel sheet.
By adding sheet name & file name inside macro, it won't run on any unnecessary excel file.
- Moss LevensonApr 13, 2018Copper Contributor
Excellent! Thank you for the heads up.
I wrote multiple macros, each to be used in its own tab. So, in each tab I created a button (shape) and I assigned the correct macro to that button. That way, I have to be in the active sheet to click the button, and then the macro will then apply to that sheet, which is what I want. I believe I'm all set now. Thanks!