Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default End of File Question

I have a macro that I use to strip out unwanted columns. For example I have
my wanted data in column A, B and C. What I want to do is add some text to
column D and have it copied down to the end of the file. The problem I have
is that all the files are different sizes. How can I specifiy the range in
my code to copy the text down to the end of the file instead of a certain
cell?

T.I.A.


Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"),
DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 2), Array(3, 2), Array(17, 9), Array(37,
1), Array(45, 9), _
Array(56, 9), Array(58, 9), Array(60, 9), Array(68, 9), Array(82,
9), Array(90, 9), Array( _
99, 9), Array(108, 9), Array(117, 9), Array(126, 9), Array(135, 9),
Array(144, 9), Array( _
152, 9), Array(160, 9), Array(169, 9), Array(178, 9), Array(187, 9),
Array(195, 9), Array( _
203, 9), Array(212, 9), Array(216, 9), Array(240, 9), Array(258, 9),
Array(263, 9), Array( _
286, 9), Array(294, 9)), TrailingMinusNumbers:=True
Columns("C:C").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.ColumnWidth = 26
Range("D2").Select
ActiveCell.FormulaR1C1 = "TEXT"
Range("D2").Select
Selection.AutoFill Destination:=Range("D2:D16355")
Range("D2:D16355").Select


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default End of File Question

Dayton,

Give this a whirl. Watch for wrap-around

Dim cRows As Long, i As Long

Columns("A:A").TextToColumns Destination:=Range("A1"),
DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 2), Array(3, 2), Array(17, 9), Array(37,
1), Array(45, 9), _
Array(56, 9), Array(58, 9), Array(60, 9), Array(68, 9), Array(82,
9), Array(90, 9), Array( _
99, 9), Array(108, 9), Array(117, 9), Array(126, 9), Array(135, 9),
Array(144, 9), Array( _
152, 9), Array(160, 9), Array(169, 9), Array(178, 9), Array(187, 9),
Array(195, 9), Array( _
203, 9), Array(212, 9), Array(216, 9), Array(240, 9), Array(258, 9),
Array(263, 9), Array( _
286, 9), Array(294, 9)), TrailingMinusNumbers:=True
With Columns("C:C")
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
.ColumnWidth = 26
End With

cRows = Cells(Rows.Count, "A").End(xlUp).Row
With Range("D2")
.FormulaR1C1 = "TEXT"
.AutoFill Destination:=Range("D2:D" & cRows)
End With
Range("D2:D" & cRows).Select

--

HTH

Bob Phillips

"dayton" wrote in message
...
I have a macro that I use to strip out unwanted columns. For example I

have
my wanted data in column A, B and C. What I want to do is add some text to
column D and have it copied down to the end of the file. The problem I

have
is that all the files are different sizes. How can I specifiy the range in
my code to copy the text down to the end of the file instead of a certain
cell?

T.I.A.


Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"),
DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 2), Array(3, 2), Array(17, 9), Array(37,
1), Array(45, 9), _
Array(56, 9), Array(58, 9), Array(60, 9), Array(68, 9), Array(82,
9), Array(90, 9), Array( _
99, 9), Array(108, 9), Array(117, 9), Array(126, 9), Array(135,

9),
Array(144, 9), Array( _
152, 9), Array(160, 9), Array(169, 9), Array(178, 9), Array(187,

9),
Array(195, 9), Array( _
203, 9), Array(212, 9), Array(216, 9), Array(240, 9), Array(258,

9),
Array(263, 9), Array( _
286, 9), Array(294, 9)), TrailingMinusNumbers:=True
Columns("C:C").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.ColumnWidth = 26
Range("D2").Select
ActiveCell.FormulaR1C1 = "TEXT"
Range("D2").Select
Selection.AutoFill Destination:=Range("D2:D16355")
Range("D2:D16355").Select




Reply
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
hello everybody.. question about .csv file... yakir Excel Discussion (Misc queries) 3 May 24th 10 06:11 PM
Question on saving a file. Crissyb Excel Discussion (Misc queries) 5 February 12th 10 06:45 PM
Excel File Question Maurice Excel Discussion (Misc queries) 3 December 23rd 09 05:59 PM
File name question stew Excel Discussion (Misc queries) 0 January 15th 09 03:54 PM
File Download Question Xterra1 Excel Discussion (Misc queries) 2 October 8th 07 10:58 PM


All times are GMT +1. The time now is 09:34 AM.

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

About Us

"It's about Microsoft Excel"