ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Dynamic Values in Procedure (https://www.excelbanter.com/excel-programming/272086-re-dynamic-values-procedure.html)

Dave Peterson[_3_]

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



All times are GMT +1. The time now is 01:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com