Hello,
I’m very new to macros, and I’m hoping I can benefit from someone’s expertise here or that maybe someone can point me in the right direction.
I have a spreadsheet with a few thousand rows. Basically, what I need it to do is insert TWO rows BELOW every value in rows 1 through 3000 in which the value TRUE appears in Cell A1 through cell A3000.
I have used the recording a macro function on Excel, but I have yet to actually write any code. Any ideas would be very helpful.
Thanks!
Andy
aheath54,
Welcome to the Excel Forum.
Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).
Adding the Macro
1. Copy the below macro, by highlighting the macro code and pressing the keys CTRL + C
2. Open your workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Paste the code by pressing the keys CTRL + V
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.
Option Explicit Sub Insert2Rows() ' stanleydgromjr, 10/20/2010, EF750085 Dim LR As Long, a As Long Application.ScreenUpdating = False LR = Cells(Rows.Count, 1).End(xlUp).Row For a = LR To 1 Step -1 If Cells(a, 1).Value = True Then Cells(a, 1).Offset(1).Resize(2).EntireRow.Insert Next a Application.ScreenUpdating = True End Sub
Then run the Insert2Rows macro.
Have a great day,
Stan
stanleydgromjr
Windows Vista Business, Excel 2003 and 2007
If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks