Macro to Copy Values from Non-Contiguous Cells (Column) to Contiguous Cells (Rows)

Snake Eyes

Board Regular
Joined
Dec 14, 2010
Messages
105
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Greetings,
I'm trying to create a macro that copies cell values from Sheet1 in non-contiguous cells (Column) to Sheet2 into contiguous cells (Row).
I need the macro to detect the next free row at the top short of affecting any row above Row5 and paste there.

Copy Values from:
Sheet1 B10,B12,B14,B17,B19,B23,B29,B32,B35,B38,B41,B43,B45,B47,B49,B51,B53

Paste values to:
Sheet 2 H6:AA6

I know I can do this one cell at a time but I'm looking to simplify the process.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Try:
VBA Code:
Sub CopyValues()
    Application.ScreenUpdating = False
    Sheets("Sheet1").Range("B10,B12,B14,B17,B19,B23,B29,B32,B35,B38,B41,B43,B45,B47,B49,B51,B53").Copy
    Sheets("Sheet2").Range("H6").PasteSpecial Transpose:=True
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thanks Mumps.
Where in the code you provide does it detect the next free row at the top of Sheet 2 short of affecting any row above Row5 and paste there?
 
Upvote 0
Try:
VBA Code:
Sub CopyValues()
    Application.ScreenUpdating = False
    Sheets("Sheet1").Range("B10,B12,B14,B17,B19,B23,B29,B32,B35,B38,B41,B43,B45,B47,B49,B51,B53").Copy
    Sheets("Sheet2").Cells(Sheets("Sheet2").Rows.Count, "H").End(xlUp).Offset(1).PasteSpecial Transpose:=True
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,507
Messages
6,179,176
Members
452,893
Latest member
denay

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