Hi perera3112,
Your request sounds a lot like "Teach me VBA" - so here we go.
I opened a new workbook and put stuff in A1, A2 and A3. Then I turned on the "Record Macro" and clicked below the last row in Column A. Then did a Ctrl+Up, moved down a Row and Inserted a row and then copied the row above it to the inserted row. I think this is what you wanted in words. I then turned off the Macro Recorder and looked at the Macro. It showed:
The recorded macro gave me the vocabulary to do what you want in general. The first problem that it didn't do was tell me the last row of data, as we know it will change.
I've memorized the following line of code:
The above will go to the bottom of any sheet in column A and do the Ctrl+Up and stop when it hits the first non-blank cell. That is the Last Row of data on my sheet.
Using the above I Edit my macro to the following:
I don't believe inserting a row below the last row will do anything that is needed so I'll throw that line out and this would leave:
Sub Macro1()
So the above code is a learning experience from recording a macro to putting in some variables (LastRow) and editing the recorded macro so it works like we want. You should learn the LastRow line above and also learn Cells(row,column) notation.
Note - I had to trial and error a few times as
wasn't understood by the Compiler. I decided to put in the ":" with the & and it finally worked.
I also forgot to put the "A" in the line of code of"
so it didn't work either the first time through. All programmers need to trial and error (or debug) their code before it works.
I hope the above (long answer) will show you how to write your own VBA in the future.
Bookmarks