Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
help with arrays
I am trying to create an array but am getting a data type
mismatch error on the ReDim statement. Can anyone tell me why? One other thing that may be important is that I have declared Cust, DocNo, DrBr, etc as public variables at the beginning of the module and assigned different data types to the variables depending on the data in the particular field. Dim i As Integer Dim Writeoffs() JVCounter = 1 ReDim Writeoffs(1 To i, Cust, DocNo, DrBr, CrBr, _ DrAcctAmt, CrAcctAmt, DrAcctNo, CrAcctNo, Descr) Any help would be greatly appreciated. Thanks. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
help with arrays
I posted tested code that works based on your description. Frankly, the
code you show demonstrates you don't seem to have a concept of how to use arrays or how they are dimensioned. given those are your fields Dim i As Integer Dim Writeoffs() Dim FieldNames as Variant JVCounter = 1 FieldNames = Array("Cust", "DocNo", "DrBr", "CrBr":, _ "DrAcctAmt", "CrAcctAmt", "DrAcctNo", "CrAcctNo", "Descr") numElem = Ubound(FieldNames,1) - Lbound(FieldNames,1) + 1 ReDim Writeoffs(1 To i, 1 to NumElem) Would be the direction you are headed. Think of the array being identical to the rows and cells of your speadsheet. You spreadsheet has two dimensions; so does the array. Your filed names would not be variables unless you are going to use variables that just happen to share the name of the fields. (but for what purpose it would be hard to fathom). -- Regards, Tom Ogilvy "mike" wrote in message ... I am trying to create an array but am getting a data type mismatch error on the ReDim statement. Can anyone tell me why? One other thing that may be important is that I have declared Cust, DocNo, DrBr, etc as public variables at the beginning of the module and assigned different data types to the variables depending on the data in the particular field. Dim i As Integer Dim Writeoffs() JVCounter = 1 ReDim Writeoffs(1 To i, Cust, DocNo, DrBr, CrBr, _ DrAcctAmt, CrAcctAmt, DrAcctNo, CrAcctNo, Descr) Any help would be greatly appreciated. Thanks. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
help with arrays
Your right. I am new to VBA and am trying to learn as
much as possible. I understand the concept of arrays and how they can be used but I am having difficulty in how they are dimensioned. If you can point me to a good resource or reference, it would be greatly appreciated. -----Original Message----- I posted tested code that works based on your description. Frankly, the code you show demonstrates you don't seem to have a concept of how to use arrays or how they are dimensioned. given those are your fields Dim i As Integer Dim Writeoffs() Dim FieldNames as Variant JVCounter = 1 FieldNames = Array("Cust", "DocNo", "DrBr", "CrBr":, _ "DrAcctAmt", "CrAcctAmt", "DrAcctNo", "CrAcctNo", "Descr ") numElem = Ubound(FieldNames,1) - Lbound(FieldNames,1) + 1 ReDim Writeoffs(1 To i, 1 to NumElem) Would be the direction you are headed. Think of the array being identical to the rows and cells of your speadsheet. You spreadsheet has two dimensions; so does the array. Your filed names would not be variables unless you are going to use variables that just happen to share the name of the fields. (but for what purpose it would be hard to fathom). -- Regards, Tom Ogilvy "mike" wrote in message ... I am trying to create an array but am getting a data type mismatch error on the ReDim statement. Can anyone tell me why? One other thing that may be important is that I have declared Cust, DocNo, DrBr, etc as public variables at the beginning of the module and assigned different data types to the variables depending on the data in the particular field. Dim i As Integer Dim Writeoffs() JVCounter = 1 ReDim Writeoffs(1 To i, Cust, DocNo, DrBr, CrBr, _ DrAcctAmt, CrAcctAmt, DrAcctNo, CrAcctNo, Descr) Any help would be greatly appreciated. Thanks. . |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
help with arrays
Here's one source to get you started. Search the page for
'Understanding Arrays'. http://www.microsoft.com/technet/tre...part2/ch07.asp HTH Paul -------------------------------------------------------------------------------------------------------------- If you can point me to a good resource or reference, it would be greatly appreciated. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
help with arrays
I post sample code specific to your situation that works. I gave you an
revised example of what you tried. Perhaps looking at these and asking questions about what you don't understand. There really isn't a whole lot of mystery to them, so you won't find pages of information written on them. -- Regards, Tom Ogilvy mike wrote in message ... Your right. I am new to VBA and am trying to learn as much as possible. I understand the concept of arrays and how they can be used but I am having difficulty in how they are dimensioned. If you can point me to a good resource or reference, it would be greatly appreciated. -----Original Message----- I posted tested code that works based on your description. Frankly, the code you show demonstrates you don't seem to have a concept of how to use arrays or how they are dimensioned. given those are your fields Dim i As Integer Dim Writeoffs() Dim FieldNames as Variant JVCounter = 1 FieldNames = Array("Cust", "DocNo", "DrBr", "CrBr":, _ "DrAcctAmt", "CrAcctAmt", "DrAcctNo", "CrAcctNo", "Descr ") numElem = Ubound(FieldNames,1) - Lbound(FieldNames,1) + 1 ReDim Writeoffs(1 To i, 1 to NumElem) Would be the direction you are headed. Think of the array being identical to the rows and cells of your speadsheet. You spreadsheet has two dimensions; so does the array. Your filed names would not be variables unless you are going to use variables that just happen to share the name of the fields. (but for what purpose it would be hard to fathom). -- Regards, Tom Ogilvy "mike" wrote in message ... I am trying to create an array but am getting a data type mismatch error on the ReDim statement. Can anyone tell me why? One other thing that may be important is that I have declared Cust, DocNo, DrBr, etc as public variables at the beginning of the module and assigned different data types to the variables depending on the data in the particular field. Dim i As Integer Dim Writeoffs() JVCounter = 1 ReDim Writeoffs(1 To i, Cust, DocNo, DrBr, CrBr, _ DrAcctAmt, CrAcctAmt, DrAcctNo, CrAcctNo, Descr) Any help would be greatly appreciated. Thanks. . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Arrays | Excel Discussion (Misc queries) | |||
Arrays | Excel Worksheet Functions | |||
Use of arrays | Excel Worksheet Functions | |||
arrays | Excel Programming | |||
Arrays | Excel Programming |