VBA for Copy & Transpose Paste

Pratapherono1

New Member
Joined
Sep 10, 2018
Messages
8
Hi VBA Expert,

Need your expertise in building a VBA to copy the data from Sheet 1 and transpose paste in Sheet 2 – As per the below format:

Sheet 1 (will have a pivot in the below format) - Data needs to be copied from this sheet:
ABCD
IDGBPUSDGrand Total
12345220675.50220675.50
11233-6180.33-6180.33
27736-18997.79-2445.00-21442.79
Grand Total-18997.79212050.17193052.38

<tbody>
</tbody>

Sheet 2 (will have a table in the below format) – Data needs to be pasted in this sheet:

ABCDEFGH
S. No.BatchDateDateTypeIDCCYAmount
1Batch17-Sep-187-Sep-18ABC12345USD220,675.50
2Batch17-Sep-187-Sep-18XYZ11233USD-6,180.33
3Batch17-Sep-187-Sep-18XYZ27736GBP-18,997.79
4Batch17-Sep-187-Sep-18XYZ27736USD-2,445.00

<tbody>
</tbody>


VBA Parameters:
* Data from column A, B & C (in Sheet 1) to be copied and pasted accordingly in F, G & H (in Sheet 2) – Please note that the data in Sheet 2 is historical – Hence, the paste should be based on next available row (in Col F) in Sheet 2.
* Sheet 2 – Col A – Should have serial number in series
* Sheet 2 – Col B – Should have the number of times – the macro is run on a given day – If it is run 1st time – then it should have Batch 1, if it is run 2nd Time – then it should have Batch 2 etc…
* Sheet 2 - Col C & D – Should have today’s date


Note 1: Data in Sheet 1 is always changed (i.e, Pivot table is refreshed all the time). However, data in Sheet 2 is static data dump – the paste should always be added to the existing list (i.e. next available row).
Note 2: In the above example – there are just 3 IDs & 2 Currencies in the pivot – there could be upto 50 IDs & 30 Currencies (might differ based on data).
Note 3: There could be IDs (in Column A of Sheet 1) – with more than 1 currency (In the above example – ID # 27736 is available in GBP & USD). Hence, it has to be split accordingly in Sheet 2.


I spend almost 4 hours a day on this manual copy & paste – your help in building a VBA will be of great save.

Thank you my lord!
Regards,
Pratap
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
I have a couple of questions.

What cells does the pivot table occupy? e.g. A3:D7?
On sheet2, where is the type coming from? e.g. ABC, XYZ

Also, to be able to set up the pivot table range I would like to know how your pivot table is set up. I'm trying to replicate it here. Do you have 2 header rows? In my test data,
A3 says 'Sum of Amount', B3 says 'Type',
A4 says 'ID', B4 says 'GBP', and C4 says 'USD'.

Is that what your pivot table looks like?
 
Upvote 0

Forum statistics

Threads
1,214,861
Messages
6,121,969
Members
449,059
Latest member
oculus

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