View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Copy selected columns from .xls to a .txt file question

As for the other question, I am only looking for two entries
of 100, so 2 single tables.


This will place the first 100 cells (line feed delimited) in Column B in the
indicated variable...

Col_B = Join(WorksheetFunction.Transpose(Range("B1:B100")) , vbLf)

and this will do the same for Column I...

Col_I = Join(WorksheetFunction.Transpose(Range("I1:I100")) , vbLf)

You can replace the 100 in each statement with a calculated value for the
Last Row if you will not have exactly 100 entries and you only want the
values for the number of cells down to the last filled in row in that
column. For example, for the Col_B variable (do similarly for the Col_I
variable)...

LastRow = Cells(Rows.Count, "B").End(xlUp).Row
Col_B = Join(WorksheetFunction.Transpose(Range("B1:B" & LastRow)), vbLf)

You can process these variables out to your file in whatever order you want.

--
Rick (MVP - Excel)