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

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

al_b_cnu

Well-known Member
Joined
Jul 18, 2003
Messages
4,494
Hi,

do you want the entire contents of C:Icopying, or just he last row?
 

al_b_cnu

Well-known Member
Joined
Jul 18, 2003
Messages
4,494
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
 

Watch MrExcel Video

Forum statistics

Threads
1,133,257
Messages
5,657,627
Members
418,404
Latest member
Sneijders

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
Top