VBA Help

Miya

Well-known Member
Joined
Nov 29, 2008
Messages
662
Hi, what is the best method to copy data from Raw to Rec and switch the value and entry columns?

Excel Workbook
ABCDEFGHIJ
1GroupRecAccountEntry DateValue DateTypeAmountCCYAgeSource
2CITIJPTEST19-Jan-1118-Jan-11SCR3.98CAD2TEST
3CITIJPTEST19-Jan-1118-Jan-11SCR10.66CAD2TEST
4CITIJPTEST19-Jan-1119-Jan-11SCR4,678.47GBP1TEST
5CITIJPTEST19-Jan-1119-Jan-11SCR77,736.95GBP1TEST
6CITIJPTEST19-Jan-1119-Jan-11LDR-54,396.71USD1TEST
7CITIJPTEST19-Jan-1119-Jan-11LDR-112,687.68BRL1TEST
8CITIJPTEST19-Jan-1119-Jan-11LDR-21,579.15BRL1TEST
9CITIJPTEST19-Jan-1119-Jan-11SDR-531,867,184.00IDR1TEST
10CITIJPTEST19-Jan-1112-Jan-11SDR-60,124,240.74PKR8TEST
11CITIJPTEST21-Dec-101-Dec-10LCR0.72TWD50TEST
12CITIJPTEST19-Jan-1119-Jan-11SCR58,582.13USD1TEST
13CITIJPTEST19-Jan-1112-Jan-11SCR700,912.11USD8TEST
14CITIJPTEST19-Jan-1119-Jan-11SCR4,459,840.00TWD1TEST
15CITIJPTEST19-Jan-1119-Jan-11SDR-154,000.00USD1TEST
16
Raw



Excel Workbook
ABCDEFGHIJ
1GroupRecAccountValue DateEntry DateTypeAmountCCYAgeSource
2CITIJPTEST18-Jan-1119-Jan-11SCR3.98CAD2TEST
3CITIJPTEST18-Jan-1119-Jan-11SCR10.66CAD2TEST
4CITIJPTEST19-Jan-1119-Jan-11SCR4,678.47GBP1TEST
5CITIJPTEST19-Jan-1119-Jan-11SCR77,736.95GBP1TEST
6CITIJPTEST19-Jan-1119-Jan-11LDR-54,396.71USD1TEST
7CITIJPTEST19-Jan-1119-Jan-11LDR-112,687.68BRL1TEST
8CITIJPTEST19-Jan-1119-Jan-11LDR-21,579.15BRL1TEST
9CITIJPTEST19-Jan-1119-Jan-11SDR-531,867,184.00IDR1TEST
10CITIJPTEST12-Jan-1119-Jan-11SDR-60,124,240.74PKR8TEST
11CITIJPTEST1-Dec-1021-Dec-10LCR0.72TWD50TEST
12CITIJPTEST19-Jan-1119-Jan-11SCR58,582.13USD1TEST
13CITIJPTEST12-Jan-1119-Jan-11SCR700,912.11USD8TEST
14CITIJPTEST19-Jan-1119-Jan-11SCR4,459,840.00TWD1TEST
15CITIJPTEST19-Jan-1119-Jan-11SDR-154,000.00USD1TEST
16
17
Rec
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Miya

Does the Rec worksheet have data in it already or are you trying to create it from the Raw worksheet?

If the Rec worksheet exists and is blank you could try something like this.
Code:
Option Explicit
 
Sub MakeRecFromRaw()
Dim wsRaw As Worksheet
Dim wsRec As Worksheet
 
    Set wsRaw = Worksheets("Raw")
    
    Set wsRec = Worksheets("Rec")
        
    wsRaw.Range("A:C").Copy wsRec.Range("A1")
    
    wsRaw.Range("E:E").Copy wsRec.Range("D1")
    
    wsRaw.Range("D:D").Copy wsRec.Range("E1")
    
    wsRaw.Range("F:J").Copy wsRec.Range("F1")
    
End Sub
 
Upvote 0
Another possibility ..

<font face=Courier New><br><SPAN style="color:#00007F">Sub</SPAN> CopyAndSwap()<br>    <SPAN style="color:#00007F">Dim</SPAN> wsRaw <SPAN style="color:#00007F">As</SPAN> Worksheet<br>    <SPAN style="color:#00007F">Dim</SPAN> wsRec <SPAN style="color:#00007F">As</SPAN> Worksheet<br> <br>    <SPAN style="color:#00007F">Set</SPAN> wsRaw = Worksheets("Raw")<br>    <SPAN style="color:#00007F">Set</SPAN> wsRec = Worksheets("Rec")<br>       <br>    <SPAN style="color:#00007F">With</SPAN> wsRec<br>        wsRaw.UsedRange.Copy Destination:=.Range("A1")<br>        .Columns("E").Cut<br>        .Columns("D").Insert<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,723
Members
452,939
Latest member
WCrawford

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