View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default Dynamic Values in Procedure

See one more suggestion at your other post.

bw wrote:

I have the following procedure, and it works as it should.

Sub OPENTHEFILE()
Workbooks.OpenText Filename:="C:\DownLoads\LAS6014", Origin:=437, StartRow _
:=1, DataType:=xlFixedWidth, FieldInfo:=Array( _
Array(Range(DA(2, 0)), Range(DA(2, 1))), _
Array(Range(DA(3, 0)), Range(DA(3, 1))), _
Array(Range(DA(4, 0)), Range(DA(4, 1))), _
Array(Range(DA(5, 0)), Range(DA(5, 1)))), _
TrailingMinusNumbers:=True
End Sub

Now I want to obtain a value for the DA array from my worksheet indicating how many
fields there will be, and then loop through the OPENTHEFILE procedure depending on
the number of fields.

So I'm looking for something like the following (although I KNOW the following is NOT
correct):

Sub OPENTHEFILE()
Workbooks.OpenText Filename:="C:\DownLoads\LAS6014", Origin:=437, StartRow _
:=1, DataType:=xlFixedWidth, FieldInfo:=Array( _
For x = 0 To VariableFromWorksheet
Array(Range(DA(x, 0)), Range(DA(x, 1))), _
Next x
TrailingMinusNumbers:=True
End Sub

Something like that! I hope you get the idea...

Can anyone help?

Thanks,
Bernie


--

Dave Peterson