MACRO FOR PASTING A ROW 28 TIMES N KEEP 1 BLANK ROW in BETWEEN PASTES

sara2009

New Member
Joined
Apr 1, 2013
Messages
16
Hii i have so mANY saleS invoices to organise before i import into a database. please give me a macro for this:

data range is in sheet2 in A2:A255 and C2:C255, D2:D255. each row has unique text data, i need to paste to sheet1 each sheet2 row 28 times followed by a blank row after every 28rows of data. e.g row2 shud be pasted 28times from A2 to A29,D2 toD29,C2 to C29 then have 1 rowspace then paste Row3 28 times from A31 to A58 for column C and D as well and have 1 row space and go on for the rest of the rows.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Code:
[color=darkblue]Sub[/color] Paste_28_Rows()
    [color=darkblue]Dim[/color] i [color=darkblue]As[/color] [color=darkblue]Long[/color], j [color=darkblue]As[/color] Long
    j = 2
    [color=darkblue]For[/color] i = 2 [color=darkblue]To[/color] 255
        Sheets("Sheet1").Range("A" & j).Resize(28).Value = _
            Sheets("Sheet2").Range("A" & i).Value
        Sheets("Sheet1").Range("C" & j).Resize(28, 2).Value = _
            Sheets("Sheet2").Range("C" & i).Resize(, 2).Value
        j = j + 29
    [color=darkblue]Next[/color] i
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
 
Upvote 0
Macros have their value but they come with accountability, security, and maintenance issues. ;)

Here's how to do what you want w/o any code.

In Sheet1 cell A2 enter the formula =IF(MOD(ROW()-ROW($A$1),29)=0,"", INDEX(Sheet2!A$2:A$5,1+INT((ROW()-ROW(Sheet1!$A$1))/29)))

Adjust A2:A5 to your actual range. A2:A5 was my test range in Sheet2.

Copy A2 down column A to cell A{29*#rows with data in Sheet2}. For confirmation go down by a few more cells and you should see at least 1 #REF! error.

Select column A2:A{whatever}, copy, select C2:D2, and paste.

It worked!!thank you alphafrog!! I nealrly gave up organising this data! Love macros!!
 
Upvote 0

Forum statistics

Threads
1,215,509
Messages
6,125,216
Members
449,215
Latest member
texmansru47

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