LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default reposting: combining multiple columns into one column - enhancements

Hello everybody,

I repost the message from "excel.worksheet.functions" forum, maybe it was
not appropriate for the questions I had (or maybe it was too complicated)...
-----------------
-----------------
I've found (on one of the excel newsgroups) a macro "combining multiple
columns into one column", apparently posted initially by Dave Peterson or
Bob Phillips.

The macro makes - for sure - the basic work, however I would be glad if
someone could help me to add 3 enhancements:

1st: my initial page contains formulas, so I would need to convert these
data into "paste special/values" (if not, the data is not copied properly).

2nd: I've noticed that when I use "ctrl + down arrow" on the columns, il
goes further than the last cell with value (in fact, it goes always until
the row 143, probably because the formula is extended until this row, even
if it returns blank cells), so it would be great if this could also be
resolved somehow... :-), because without this, there will be a lot of "free"
space between the "real" end of one column and the start of the next one...

3rd: some columns contain blank cells in the middle: what should I add to
the code (optionally) if I want to elimitate all the blank cells in the new,
combined, column?

Many thanks for your help on this...
Mark

=============================
Sub OneColumn()

''''''''''''''''''''''''''''''''''''''''''
'Macro to copy columns of variable length'
'into 1 continous column in a new sheet '
''''''''''''''''''''''''''''''''''''''''''
Dim ilastcol As Long
Dim ilastrow As Long
Dim jlastrow As Long
Dim colndx As Long
Dim ws As Worksheet
Dim myRng As Range
Dim idx As Integer

Set ws = ActiveWorkbook.ActiveSheet
ilastcol = Cells(1, Columns.Count).End(xlToLeft).Column

With Sheets.Add
.Name = "Alldata"
End With

idx = Sheets("Alldata").Index
Sheets(idx + 1).Activate

For colndx = 1 To ilastcol

ilastrow = ws.Cells(Rows.Count, colndx).End(xlUp).Row
jlastrow = Sheets("Alldata").Cells(Rows.Count, 1) _
.End(xlUp).Row

Set myRng = Range(Cells(1, colndx), _
Cells(ilastrow, colndx))
With myRng
.Copy Sheets("Alldata").Cells(jlastrow + 1, 1)
End With
Next

Sheets("Alldata").Rows("1:1").EntireRow.Delete

End Sub


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
combining multiple columns from multiple files osiris73 Excel Discussion (Misc queries) 2 January 17th 07 03:30 AM
Help combining multiple columns into one [email protected] Excel Discussion (Misc queries) 8 December 28th 06 09:49 PM
Combining 1 column into many columns Help @ Work Excel Discussion (Misc queries) 4 October 4th 06 11:07 PM
Combining Multiple Columns into One J.J. Excel Worksheet Functions 3 March 21st 06 03:25 PM
combining multiple columns into one column - enhancements markx Excel Worksheet Functions 0 February 16th 06 03:12 PM


All times are GMT +1. The time now is 05:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"