Row Pasting

Divakarkumar

New Member
Joined
Jul 31, 2020
Messages
9
Office Version
  1. 2016
Platform
  1. Windows
Hi All,

I’m automating one task, I have calculation sheet which contains the pivot table (A5:C18) and each row I need to paste in Sheet2 worksheet 3 times the same value and when it comes to next iteration in the loop it has given 2 blank rows and paste in sheet 2.

I have developed pies of code, but if condition is not satisfying, not sure my code is correct or wrong.

Great if some one helps on this

Code :
===================================
Sub CopyPastMultipleTimes()

Dim q As Long, p As Long
Dim wsl As Worksheet
Dim co As Variant
Set wsl = Worksheets("Calculation")
Lasrow = wsl.Range("A" & Rows.Count).End(xlUp).Row

wsl.Activate

For p = 5 To lastrow
If wsl.Cells(p, 1) = co Then

For q = 1 To 3
wsl.Range(Cells(p, 1), Cells(p, 2)).Copy Destination:=Worksheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(2)

Next q
End If

Next p
End Sub

Sample data set;

Sheet Name : Calculation (Input sheet)
COICEnt. CurrSum of Entered DEBIT/CREDITSum of Accounted DEBIT/CREDIT
630310EUR132,495148,437
630631HKD658,04284,858
630631THB1,444,50045,258
630631AUD250,631161,281
630631INR23,239,770306,765
631310EUR(327,877)(367,329)
631630HKD(658,042)(84,858)
631630THB(1,444,500)(45,258)
631630AUD(250,631)(161,281)
631630INR(23,239,770)(306,765)
631300EUR(2,357,890)(2,641,597)
631300GBP1,2691,563
631300CHF(198,564)(209,147)
631300ZAR5,388311
Grand Total(2,745,179)(3,067,762)



Out Put sheet :

Data should be like this

COICEnt. CurrSum of Entered DEBIT/CREDITSum of Accounted DEBIT/CREDIT
630​
310​
EUR132,495148,437
630​
310​
EUR132,495148,437
630​
310​
EUR132,495148,437
630​
631​
HKD658,04284,858
630​
631​
HKD658,04284,858
630​
631​
HKD658,04284,858
 

Attachments

  • 1596720550288.png
    1596720550288.png
    31.3 KB · Views: 1

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
What is co? You need to give co a value.
 
Upvote 0

Forum statistics

Threads
1,215,853
Messages
6,127,328
Members
449,376
Latest member
karenmccabe

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