Cutting and pasting 90+ columns into 1 column
Closed
beladrian
-
Jun 25, 2009 at 11:01 PM
Excelguru
Excelguru
- Posts
- 261
- Registration date
- Saturday April 11, 2009
- Status
- Member
- Last seen
- June 21, 2011
Related:
- Cutting and pasting 90+ columns into 1 column
- How to copy and paste a column in excel to another sheet - Guide
- Copy and Paste certain columns based on dates ✓ - Forum - Excel
- Disable cut copy paste in windows - Forum - Windows 7
- VBA copy/paste cells then drop 1 row for next ✓ - Forum - Excel
- Excel vba cut and paste row to another sheet based on cell value - Forum - Excel
4 replies
Hi Excelguru,
Thanks for your prompt reply!
Is this the way it should look?
I am getting a runtime error.
Would this loop through all the other other 90+ columns in that sheet automatically?
Thanks again in advance!
Sub CombineColumns()
'Copy column b to Column a
Columns("b").Copy Destination:=Columns("A")
NewRowA = Range("A" & Rows.Count).End(xlUp).Row + 1
LastRowB = Range("c" & Rows.Count).End(xlUp).Row
Set CopyRange = Range("c1:c" & LastRowc)
CopyRange.Cut
Range("A" & NewRowA).Select
ActiveSheet.Paste
NewRowA = Range("A" & Rows.Count).End(xlUp).Row + 1
LastRowc = Range("d" & Rows.Count).End(xlUp).Row
Set CopyRange = Range("d1:d" & LastRowd)
CopyRange.Cut
Range("A" & NewRowA).Select
ActiveSheet.Paste
End Sub
Thanks for your prompt reply!
Is this the way it should look?
I am getting a runtime error.
Would this loop through all the other other 90+ columns in that sheet automatically?
Thanks again in advance!
Sub CombineColumns()
'Copy column b to Column a
Columns("b").Copy Destination:=Columns("A")
NewRowA = Range("A" & Rows.Count).End(xlUp).Row + 1
LastRowB = Range("c" & Rows.Count).End(xlUp).Row
Set CopyRange = Range("c1:c" & LastRowc)
CopyRange.Cut
Range("A" & NewRowA).Select
ActiveSheet.Paste
NewRowA = Range("A" & Rows.Count).End(xlUp).Row + 1
LastRowc = Range("d" & Rows.Count).End(xlUp).Row
Set CopyRange = Range("d1:d" & LastRowd)
CopyRange.Cut
Range("A" & NewRowA).Select
ActiveSheet.Paste
End Sub
Excelguru
Jun 27, 2009 at 08:59 AM
- Posts
- 261
- Registration date
- Saturday April 11, 2009
- Status
- Member
- Last seen
- June 21, 2011
Jun 27, 2009 at 08:59 AM
Hi beladrian
instead of CopyRange.Copy Destination:=Range("A" & NewRowA) use
instead of CopyRange.Copy Destination:=Range("A" & NewRowA) use
CopyRange.Cut Range("A" & NewRowA).Select ActiveSheet.Paste
Excelguru
Jun 29, 2009 at 04:23 AM
- Posts
- 261
- Registration date
- Saturday April 11, 2009
- Status
- Member
- Last seen
- June 21, 2011
Jun 29, 2009 at 04:23 AM
Hi beladrian
You have made a spelling mistake in the code
LastRowc = Range("d" & Rows.Count).End(xlUp).Row
Set CopyRange = Range("d1:d" & LastRowd)
You have made a spelling mistake in the code
LastRowc = Range("d" & Rows.Count).End(xlUp).Row
Set CopyRange = Range("d1:d" & LastRowd)
Excelguru
Aug 29, 2009 at 04:34 AM
- Posts
- 261
- Registration date
- Saturday April 11, 2009
- Status
- Member
- Last seen
- June 21, 2011
Aug 29, 2009 at 04:34 AM
LastRowc = Range("d" & Rows.Count).End(xlUp).Row
Set CopyRange = Range("d1:d" & LastRowd)
I just meant that instead of LastRowc he used LastRowd in the second line.
This caused the error as excel could not find the value of LastRowd and hence it took the value as zero
There is no zeroth row or column in excel
Set CopyRange = Range("d1:d" & LastRowd)
I just meant that instead of LastRowc he used LastRowd in the second line.
This caused the error as excel could not find the value of LastRowd and hence it took the value as zero
There is no zeroth row or column in excel