combine lists

sburkhar

Active Member
Joined
Oct 4, 2006
Messages
363
is there a way to combine the info from several columns into 1 list?

All of my columns have information in rows 1-20, but I want it all to automatically combine into a list in column B on a new sheet.

This is Excel 2007
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
This should be a good place to start. (I'm using xl'03 here but it should be the same for '07.)

All this will do is just what you've posted - pasting to column B of Sheet2. (No sorting, testing or anything fancy.)
Code:
Sub CopyAllColumnsToSheet2ColumnB()
Dim EndRw As Long, EndCol As Long, Col As Long
EndRw = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
EndCol = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
For Col = 1 To EndCol
  Range(Cells(1, Col), Cells(EndRw, Col)).Copy Sheets("Sheet2").Cells(Rows.Count, "B").End(xlUp)(2)
Next Col
End Sub
Hope it helps.

EDIT:
This copies the entire column of information. If you want to limit it to just rows 1:20 that's easy enough to do.
 
Last edited:
Upvote 0
Hi SBurkhar,

Yes there is a way to combine everything into one list. You can use the concatenate function or you can write a formula. I've included an example of a formula below:

=existing!A4&" "&existing!B4&" "&existing!C4

I used the name existing for the worksheet with the existing data set.

Hope this helps.
Peg
 
Upvote 0
Concantenate combines everything in the cells into one cell...right?.

I'm looking for a running list of the part numbers. So, instead of having 4 columns with part numbers in rows 1-20, I end will up with one column with part numbers in rows 1-80
 
Upvote 0
The macro looks promising, but I need to select certain columns from the spreadsheet. This macro looks like it encompasses all the columns.
 
Upvote 0
So, instead of having 4 columns with part numbers in rows 1-20, I end will up with one column with part numbers in rows 1-80
yes, either Peg's formula approach or a vba approach (like posted above), can each do that.
 
Upvote 0
Yes, right now it does include all columns with data.
You want to limit it to specific columns or rows? Which ones?
 
Upvote 0
Does this macro do what you want?

Code:
Sub CombineColumnsIntoSingleColumn()
  Dim Col As Range, OutputCell As Range
  Const ColumnsToCombine = "A:A,C:D,F:F"
  Const RowsToCombine = "1:20"
  Const OutputSheet As String = "Sheet5"
  Const OutputStartCell As String = "A1"
  Set OutputCell = Worksheets(OutputSheet).Range(OutputStartCell)
  For Each Col In Range(ColumnsToCombine).Columns
    Intersect(Rows(RowsToCombine), Col).Copy OutputCell
    Set OutputCell = OutputCell.Offset(Rows(RowsToCombine).Count)
  Next
End Sub
Just change each of the constants (Const statements) to match your actual setup (the constant names should be obvious as to what they point to). Note the method used to define the columns in the ColumnsToCombine constant... single, stand-alone columns are specified as a range (column letter, colon, column letter again), ranges of columns are specified as would be expected... all ranges are comma delimited.
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,220
Members
452,895
Latest member
BILLING GUY

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