![]() |
VB error
Would like to know the correct statement that make the following VB works
Sub import01() Dim hfile(1 To 8), i As Integer hfile1 = "T:\Abc\Consolid\htmPL\PLY.HTM" hfile2 = "T:\Abc\Consolid\htmPL\PLB.HTM" hfile3 = "T:\Abc\Consolid\htmPL\PLL.HTM" hfile4 = "T:\Abc\Consolid\htmPL\PLPP.HTM" hfile5 = "T:\Abc\Consolid\htmPL\PLR.HTM" hfile6 = "T:\Abc\Consolid\htmPL\PLT.HTM" hfile7 = "T:\Abc\Consolid\htmPL\PLSMHK.HTM" hfile8 = "T:\Abc\Consolid\htmPL\PLSMH.HTM" For i = 1 To 8 Workbooks.Open Filename:=hfile(i) ... vb code ... vb code ... vb code Next End sub -- aw |
VB error
Sub import01()
Dim hfile(7), i As Integer hfile(0) = "T:\Abc\Consolid\htmPL\PLY.HTM" hfile(1) = "T:\Abc\Consolid\htmPL\PLB.HTM" hfile(2) = "T:\Abc\Consolid\htmPL\PLL.HTM" hfile(3) = "T:\Abc\Consolid\htmPL\PLPP.HTM" hfile(4) = "T:\Abc\Consolid\htmPL\PLR.HTM" hfile(5) = "T:\Abc\Consolid\htmPL\PLT.HTM" hfile(6) = "T:\Abc\Consolid\htmPL\PLSMHK.HTM" hfile(7) = "T:\Abc\Consolid\htmPL\PLSMH.HTM" For i = 0 To 7 Workbooks.Open Filename:=hfile(i) '.. vb code '.. vb code '.. vb code Next End Sub hth Carlo On Dec 13, 12:53 pm, aw wrote: Would like to know the correct statement that make the following VB works Sub import01() Dim hfile(1 To 8), i As Integer hfile1 = "T:\Abc\Consolid\htmPL\PLY.HTM" hfile2 = "T:\Abc\Consolid\htmPL\PLB.HTM" hfile3 = "T:\Abc\Consolid\htmPL\PLL.HTM" hfile4 = "T:\Abc\Consolid\htmPL\PLPP.HTM" hfile5 = "T:\Abc\Consolid\htmPL\PLR.HTM" hfile6 = "T:\Abc\Consolid\htmPL\PLT.HTM" hfile7 = "T:\Abc\Consolid\htmPL\PLSMHK.HTM" hfile8 = "T:\Abc\Consolid\htmPL\PLSMH.HTM" For i = 1 To 8 Workbooks.Open Filename:=hfile(i) .. vb code .. vb code .. vb code Next End sub -- aw |
VB error
While the Dim statement 'carlo' showed you is one way to do it (although his
code assume the default Option Base of 0), your Dim statement is fine too. I'm a little surprised you got the assignment statements wrong given you used the array syntax correctly later on inside your For-Next loop. The key to working with arrays comes from the structure of the Dim statement... the array name followed by an opening parenthesis, followed by and index number followed by a closing parenthesis... you use this structure for assignments as well as for accessing the contents of a particular element of an array. So, your assignment statements should look like this.... hfile(1) = "T:\Abc\Consolid\htmPL\PLY.HTM" hfile(2) = "T:\Abc\Consolid\htmPL\PLB.HTM" hfile(3) = "T:\Abc\Consolid\htmPL\PLL.HTM" etc. One thing you may want to consider though.... declaring your array with a data type. As you wrote it, the array will be Variants... but since you are assigning String values to the array, it would be more efficient to declare the array as data type String.... Dim hfile(1 To 8) As String, i As Integer Rick "aw" wrote in message ... Would like to know the correct statement that make the following VB works Sub import01() Dim hfile(1 To 8), i As Integer hfile1 = "T:\Abc\Consolid\htmPL\PLY.HTM" hfile2 = "T:\Abc\Consolid\htmPL\PLB.HTM" hfile3 = "T:\Abc\Consolid\htmPL\PLL.HTM" hfile4 = "T:\Abc\Consolid\htmPL\PLPP.HTM" hfile5 = "T:\Abc\Consolid\htmPL\PLR.HTM" hfile6 = "T:\Abc\Consolid\htmPL\PLT.HTM" hfile7 = "T:\Abc\Consolid\htmPL\PLSMHK.HTM" hfile8 = "T:\Abc\Consolid\htmPL\PLSMH.HTM" For i = 1 To 8 Workbooks.Open Filename:=hfile(i) .. vb code .. vb code .. vb code Next End sub -- aw |
VB error
Hey Rick
thanks for writing the additional Information. Just a question though: he was talking about VB, so does it really matter if he assigns a Data Type or not? I thought VB only works with Variants, regardless on which Data Type you work with! Please correct me if I'm wrong. thanks Carlo On Dec 13, 3:43 pm, "Rick Rothstein \(MVP - VB\)" wrote: While the Dim statement 'carlo' showed you is one way to do it (although his code assume the default Option Base of 0), your Dim statement is fine too. I'm a little surprised you got the assignment statements wrong given you used the array syntax correctly later on inside your For-Next loop. The key to working with arrays comes from the structure of the Dim statement... the array name followed by an opening parenthesis, followed by and index number followed by a closing parenthesis... you use this structure for assignments as well as for accessing the contents of a particular element of an array. So, your assignment statements should look like this.... hfile(1) = "T:\Abc\Consolid\htmPL\PLY.HTM" hfile(2) = "T:\Abc\Consolid\htmPL\PLB.HTM" hfile(3) = "T:\Abc\Consolid\htmPL\PLL.HTM" etc. One thing you may want to consider though.... declaring your array with a data type. As you wrote it, the array will be Variants... but since you are assigning String values to the array, it would be more efficient to declare the array as data type String.... Dim hfile(1 To 8) As String, i As Integer Rick "aw" wrote in message ... Would like to know the correct statement that make the following VB works Sub import01() Dim hfile(1 To 8), i As Integer hfile1 = "T:\Abc\Consolid\htmPL\PLY.HTM" hfile2 = "T:\Abc\Consolid\htmPL\PLB.HTM" hfile3 = "T:\Abc\Consolid\htmPL\PLL.HTM" hfile4 = "T:\Abc\Consolid\htmPL\PLPP.HTM" hfile5 = "T:\Abc\Consolid\htmPL\PLR.HTM" hfile6 = "T:\Abc\Consolid\htmPL\PLT.HTM" hfile7 = "T:\Abc\Consolid\htmPL\PLSMHK.HTM" hfile8 = "T:\Abc\Consolid\htmPL\PLSMH.HTM" For i = 1 To 8 Workbooks.Open Filename:=hfile(i) .. vb code .. vb code .. vb code Next End sub -- aw- Hide quoted text - - Show quoted text - |
VB error
VB, as does VBA, works with data types, it is VBScript that uses all
variants. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "carlo" wrote in message ... Hey Rick thanks for writing the additional Information. Just a question though: he was talking about VB, so does it really matter if he assigns a Data Type or not? I thought VB only works with Variants, regardless on which Data Type you work with! Please correct me if I'm wrong. thanks Carlo On Dec 13, 3:43 pm, "Rick Rothstein \(MVP - VB\)" wrote: While the Dim statement 'carlo' showed you is one way to do it (although his code assume the default Option Base of 0), your Dim statement is fine too. I'm a little surprised you got the assignment statements wrong given you used the array syntax correctly later on inside your For-Next loop. The key to working with arrays comes from the structure of the Dim statement... the array name followed by an opening parenthesis, followed by and index number followed by a closing parenthesis... you use this structure for assignments as well as for accessing the contents of a particular element of an array. So, your assignment statements should look like this.... hfile(1) = "T:\Abc\Consolid\htmPL\PLY.HTM" hfile(2) = "T:\Abc\Consolid\htmPL\PLB.HTM" hfile(3) = "T:\Abc\Consolid\htmPL\PLL.HTM" etc. One thing you may want to consider though.... declaring your array with a data type. As you wrote it, the array will be Variants... but since you are assigning String values to the array, it would be more efficient to declare the array as data type String.... Dim hfile(1 To 8) As String, i As Integer Rick "aw" wrote in message ... Would like to know the correct statement that make the following VB works Sub import01() Dim hfile(1 To 8), i As Integer hfile1 = "T:\Abc\Consolid\htmPL\PLY.HTM" hfile2 = "T:\Abc\Consolid\htmPL\PLB.HTM" hfile3 = "T:\Abc\Consolid\htmPL\PLL.HTM" hfile4 = "T:\Abc\Consolid\htmPL\PLPP.HTM" hfile5 = "T:\Abc\Consolid\htmPL\PLR.HTM" hfile6 = "T:\Abc\Consolid\htmPL\PLT.HTM" hfile7 = "T:\Abc\Consolid\htmPL\PLSMHK.HTM" hfile8 = "T:\Abc\Consolid\htmPL\PLSMH.HTM" For i = 1 To 8 Workbooks.Open Filename:=hfile(i) .. vb code .. vb code .. vb code Next End sub -- aw- Hide quoted text - - Show quoted text - |
VB error
Sorry, my bad.
Thanks for telling me. Carlo On Dec 13, 5:48 pm, "Bob Phillips" wrote: VB, as does VBA, works with data types, it is VBScript that uses all variants. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "carlo" wrote in message ... Hey Rick thanks for writing the additional Information. Just a question though: he was talking about VB, so does it really matter if he assigns a Data Type or not? I thought VB only works with Variants, regardless on which Data Type you work with! Please correct me if I'm wrong. thanks Carlo On Dec 13, 3:43 pm, "Rick Rothstein \(MVP - VB\)" wrote: While the Dim statement 'carlo' showed you is one way to do it (although his code assume the default Option Base of 0), your Dim statement is fine too. I'm a little surprised you got the assignment statements wrong given you used the array syntax correctly later on inside your For-Next loop. The key to working with arrays comes from the structure of the Dim statement... the array name followed by an opening parenthesis, followed by and index number followed by a closing parenthesis... you use this structure for assignments as well as for accessing the contents of a particular element of an array. So, your assignment statements should look like this.... hfile(1) = "T:\Abc\Consolid\htmPL\PLY.HTM" hfile(2) = "T:\Abc\Consolid\htmPL\PLB.HTM" hfile(3) = "T:\Abc\Consolid\htmPL\PLL.HTM" etc. One thing you may want to consider though.... declaring your array with a data type. As you wrote it, the array will be Variants... but since you are assigning String values to the array, it would be more efficient to declare the array as data type String.... Dim hfile(1 To 8) As String, i As Integer Rick "aw" wrote in message ... Would like to know the correct statement that make the following VB works Sub import01() Dim hfile(1 To 8), i As Integer hfile1 = "T:\Abc\Consolid\htmPL\PLY.HTM" hfile2 = "T:\Abc\Consolid\htmPL\PLB.HTM" hfile3 = "T:\Abc\Consolid\htmPL\PLL.HTM" hfile4 = "T:\Abc\Consolid\htmPL\PLPP.HTM" hfile5 = "T:\Abc\Consolid\htmPL\PLR.HTM" hfile6 = "T:\Abc\Consolid\htmPL\PLT.HTM" hfile7 = "T:\Abc\Consolid\htmPL\PLSMHK.HTM" hfile8 = "T:\Abc\Consolid\htmPL\PLSMH.HTM" For i = 1 To 8 Workbooks.Open Filename:=hfile(i) .. vb code .. vb code .. vb code Next End sub -- aw- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text - |
All times are GMT +1. The time now is 08:04 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com