Copy the data in the amount of columns specified by a cell

imagana

New Member
Joined
Apr 8, 2014
Messages
10
Hi, I am looking to see if there is any way I can copy the data in the amount of columns specified by cell "A1".

For example,
Sheet 1
A1: 3 (Column Count that data should copy from)
B3 to end of data
C3 to end of data
D3 to end of data

The idea is to copy the amount of columns specified by A1.

And paste it to sheet 2, all data, in column "A" pasted in the next available blank row.
Data in B3
Data in B4
Data in B5
Data in B6
Data in B7
.
.
.
.
Data in last cell in "B"
Data in C3
Data in C4
Data in C5
Data in C6
Data in C7
.
.
.
Data in last cell in "C"
Data in D3
Data in D4
Data in D5
Data in D6
Data in D7
.
.
.
Data in last cell in "D"

Any help is greatly appreciated.

Thank you,

Idalia
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
This is almost like the other one. Although not stated, your exeample implies that the column count should begin with column B and that is how the code is written.
Code:
Sub cpyNpstCol()
Dim sh1 As Worksheet, sh2 As Worksheet, lr As Long
Set sh1 = Sheets(1) 'Edit sheet name
Set sh2 = Sheets(2) 'Edit sheet name
lr = sh1.Cells.Find("*", sh1.Range("A1"), xlFormulas, xlPart, xlByRows, xlPrevious).Row
    For i = 1 To sh1.Range("A1").Value
        With sh1
            .Range(.Cells(3, i + 1), .Cells(lr, i + 1)).Copy sh2.Cells(Rows.Count, 1).End(xlUp)(2)
        End With
    Next
End Sub
 
Upvote 0
:) Thank you once again JLGWhiz you have once again saved my life! :pray:

It works miracles!! Thank you!!
 
Upvote 0

Forum statistics

Threads
1,216,226
Messages
6,129,606
Members
449,520
Latest member
TBFrieds

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