Archiving data horizontally

sobrien

Board Regular
Joined
Feb 28, 2006
Messages
179
I want to create a macro to archive data from a sheet into another sheet and create a continuous horizontal list. As follows:
I want to copy columns C:I in sheet "Accounts" and then paste into sheet "Account history" but so it pastes onto the next column at the end of the existing data.


Thanks
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Try this:
Code:
Option Explicit

Sub TransposeData()
Dim iToCol As Integer
Dim rFrom As Range
Dim wsFr As Worksheet, wsTo As Worksheet

Set wsFr = Sheets("Accounts")
Set wsTo = Sheets("Accounts History")
iToCol = wsTo.Cells(1, Columns.Count).End(xlToLeft).Column + 1

Set rFrom = Intersect(wsFr.Columns("C:I"), wsFr.UsedRange)

rFrom.Copy
wsTo.Range(Cells(1, iToCol).Address).PasteSpecial Paste:=xlPasteValues, Transpose:=True
Application.CutCopyMode = False

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,525
Messages
6,120,051
Members
448,940
Latest member
mdusw

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