Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I hope somebody can please help asap. I have a huge computer
programming exam tomorrow and I do not understand how to use the redim statement with dynamic arrays or how to call a subroutine. I have to know how to do both by tomorrow. Could sombody please break it down to me. I have been reading excel 2007 vba for dummies but it kind of skips over these two areas. |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Have you looked at http://support.microsoft.com/kb/142134 (which was the
first thing Google found on the subject)? -- David Biddulph wrote in message ... I hope somebody can please help asap. I have a huge computer programming exam tomorrow and I do not understand how to use the redim statement with dynamic arrays or how to call a subroutine. I have to know how to do both by tomorrow. Could sombody please break it down to me. I have been reading excel 2007 vba for dummies but it kind of skips over these two areas. |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
When you declare a dynamic array, use the following syntax:
Dim myArray() as Integer At that point, the size is not determined. You use the ReDim statement as follows: ReDim myArray(20) This will create an array of 20 elements. The first element is referred to as follows: myArray(lBound(myArray)) = 1 The last element is referred to as follows: myArray(uBound(myArray)) = 2 If you ReDim the array again, all the data in it will be overwritten. To leave the data, you use the Preserve keyword: ReDim Preserve myArray(50) Doing so will leave intact the first 20 items (if you have populated them), and create 30 new ones. Here's a subroutine example. I'll call the subroutine mySub: Public Sub mySub() ' do stuff here End Sub Now, let's say your main routine is called MainRoutine, which calls mySub: Public Sub MainRoutine() Call mySub() End Sub On Nov 28, 2:12 pm, wrote: I hope somebody can please help asap. I have a huge computer programming exam tomorrow and I do not understand how to use the redim statement with dynamic arrays or how to call a subroutine. I have to know how to do both by tomorrow. Could sombody please break it down to me. I have been reading excel 2007 vba for dummies but it kind of skips over these two areas. |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Unless you do something special:
ReDim myArray(20) will result in an array with 21 elements. It'll be the same as: ReDim myArray(0 to 20) I find that always specifying the upper and lower bounds makes the code more self-documenting. iliace wrote: When you declare a dynamic array, use the following syntax: Dim myArray() as Integer At that point, the size is not determined. You use the ReDim statement as follows: ReDim myArray(20) This will create an array of 20 elements. The first element is referred to as follows: myArray(lBound(myArray)) = 1 The last element is referred to as follows: myArray(uBound(myArray)) = 2 If you ReDim the array again, all the data in it will be overwritten. To leave the data, you use the Preserve keyword: ReDim Preserve myArray(50) Doing so will leave intact the first 20 items (if you have populated them), and create 30 new ones. Here's a subroutine example. I'll call the subroutine mySub: Public Sub mySub() ' do stuff here End Sub Now, let's say your main routine is called MainRoutine, which calls mySub: Public Sub MainRoutine() Call mySub() End Sub On Nov 28, 2:12 pm, wrote: I hope somebody can please help asap. I have a huge computer programming exam tomorrow and I do not understand how to use the redim statement with dynamic arrays or how to call a subroutine. I have to know how to do both by tomorrow. Could sombody please break it down to me. I have been reading excel 2007 vba for dummies but it kind of skips over these two areas. -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Pasting a chart from Excel 2007 to Word 2007 trouble | Charts and Charting in Excel | |||
Need to test MS Office 2007 Compatibility Pack | Excel Discussion (Misc queries) | |||
Best VBA test for 2007 in Compatibility Mode? | Excel Discussion (Misc queries) | |||
Calculate mean of test scores from rows of test answers | Excel Discussion (Misc queries) | |||
test..where are my messages..test | New Users to Excel |