Macro to copy cell from one worksheet to another

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi I currently have a workbook that contains two worksheets 'results' and
'data'

The information currently runs in two rows across the page a1, b1, c1, d1,
e1 etc. needs to become a1, a2, a3, a4, a5

and a2, b2, c2, d2, e2, needs to become b1, b2, b3, b4, b5 etc.

Any suggestions on the easiest way to do this?

Cheers,

Allan
 
Option Explicit
Sub Macro1()
Dim iNumRows As Integer, iNumCol As Integer, r As Integer, c As Integer
iNumRows = Sheets("data").UsedRange.Rows.Count
iNumCol = Sheets("data").UsedRange.Columns.Count
For r = 1 To iNumRows
For c = 1 To iNumCol
Sheets("result").Cells(c, r) = Sheets("data").Cells(r, c)
Next
Next

End Sub
 
Hello,

I think you can do this via a Paste function with the Transpose
indication = True.

I have recorded a small macro which does this job.

Sheets("Sheet1").Select
Range("A1:C3").Select
Selection.Copy
Sheets("Sheet2").Select
Selection.PasteSpecial Paste:=xlPasteAll, peration:=xlNone, SkipBlanks:=
False, Transpose:=True

kind regards,

Filip Henderieckx
 
Ta guys, both really helped me out of a sticky situation.

Cheers,

Allan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top