I don't know how complicated or simple this is, but I urgently need a macro that does the following for 372 rows.
Copy one row, duplicate it (either into a new sheet or on the current sheet) so that there are now 4 instances of the row, then append different bits of text to the cell in the first column of each of these four rows (append "-43", "-6", "-8", and "-10" respectively).
I know I probably did a horrible job of describing that, so I have attached an XLSX book. The "Beginning" sheet is a very condensed example of what I have now. The "End" sheet is what it would look like after the macro has been executed.
Obviously, doing this manually to 372 rows would be very time consuming and I really need to have this done soon.
Thank you very very much to whoever can help!
Edit: I have also uploaded the example workbook as a XLS file.
Last edited by artizhay; 07-22-2010 at 02:19 AM.
Try this:
Option Explicit Sub TimesFourPLUS() Dim LR As Long Dim Rw As Long Dim Val As String Application.ScreenUpdating = False LR = Range("A" & Rows.Count).End(xlUp).Row For Rw = LR To 1 Step -1 Rows(Rw).Copy Range("A" & Rw + 1).Resize(3).EntireRow.Insert Val = Range("A" & Rw) Range("A" & Rw) = Val & "-43" Range("A" & Rw + 1) = Val & "-8" Range("A" & Rw + 2) = Val & "-8" Range("A" & Rw + 3) = Val & "-10" Next Rw Application.ScreenUpdating = True Application.CutCopyMode = False End Sub
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
artizhay;
Here's a file that does it for you.
In the macro "Duplicate_And_Append", change the area between the '************** to fit your workbook.
The macro puts the results 2 rows below the last row in column "A" of whatever sheet you set shSheetTo to. So when you open my file and just run "Duplicate_And_Append" you will see the results create a 3rd copy on Sheet3.
Hi, this problem is very similar to mine. However I am very ignorant on how to create macros (I assume that is what you have described) - could you please tell me where and how to enter this formula?
Hi, this problem is very similar to mine. However I am very ignorant on how to create macros (I assume that is what you have described) - could you please tell me where and how to enter this formula?
(My apologies foxguy I meant to post this to JBeaucaire)
This is the programming forum. Macros are installed into code modules in the VB editor, unlike formulas which are typed directly into cells.
Please post a thread of your own with supporting documentation, outline your issue, add a sample workbook, etc. If you find other threads relevant to your issue, put a link to them in your new thread. Be sure to pick the correct forum, programming or general.
Be sure to read through the Forum Rules so you can use and follow them effectively.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks