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
 

Some videos you may like

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

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
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,105,971
Messages
5,508,473
Members
408,688
Latest member
Bhojraj

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top