Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default vba clearing out values stored in array


I have an array in a loop.
The first pass thru the loop it collects values and stores them in the
array, if i have conditions set for the second pass thru the loop and
the array doesnt reset(so to speak) and no values are to be stored, i
find that the array still carries all the old values from the first
pass.

My question is, how can i make sure my array is empty before it goes
thru the loop again??
here is a bit of what i have for code: the array varies in size each
time.

Set rng = Range("D" & J + K, "N" & J + K)
count = 1

For Each c In rng


If (Not IsEmpty(c) And IsNumeric(c)) Then
Select Case c.Font.ColorIndex
Case xlAutomatic, 1
ReDim Preserve meanArray(1 To count)

meanArray(count) = c.Value
count = count + 1
End Select

thanks alot for everyones help.


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default vba clearing out values stored in array

Set rng = Range("D" & J + K, "N" & J + K)
count = 1

' since you know the max number of elements, do a redim with
' no preserve
ReDim meanArray(1 to rng.Count)
For Each c In rng
If (Not IsEmpty(c) And IsNumeric(c)) Then
Select Case c.Font.ColorIndex
Case xlAutomatic, 1
meanArray(count) = c.Value
count = count + 1
End Select
end if
Next

Redim Preserve meanArray(1 to count-1)



--
Regards,
Tom Ogilvy

"chick-racer" wrote in message
...

I have an array in a loop.
The first pass thru the loop it collects values and stores them in the
array, if i have conditions set for the second pass thru the loop and
the array doesnt reset(so to speak) and no values are to be stored, i
find that the array still carries all the old values from the first
pass.

My question is, how can i make sure my array is empty before it goes
thru the loop again??
here is a bit of what i have for code: the array varies in size each
time.

Set rng = Range("D" & J + K, "N" & J + K)
count = 1

For Each c In rng


If (Not IsEmpty(c) And IsNumeric(c)) Then
Select Case c.Font.ColorIndex
Case xlAutomatic, 1
ReDim Preserve meanArray(1 To count)

meanArray(count) = c.Value
count = count + 1
End Select

thanks alot for everyones help.


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to

creating financial statements


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default vba clearing out values stored in array

Also look in Excel VBA help at ERASE.

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
Set rng = Range("D" & J + K, "N" & J + K)
count = 1

' since you know the max number of elements, do a redim with
' no preserve
ReDim meanArray(1 to rng.Count)
For Each c In rng
If (Not IsEmpty(c) And IsNumeric(c)) Then
Select Case c.Font.ColorIndex
Case xlAutomatic, 1
meanArray(count) = c.Value
count = count + 1
End Select
end if
Next

Redim Preserve meanArray(1 to count-1)



--
Regards,
Tom Ogilvy

"chick-racer" wrote in message
...

I have an array in a loop.
The first pass thru the loop it collects values and stores them in the
array, if i have conditions set for the second pass thru the loop and
the array doesnt reset(so to speak) and no values are to be stored, i
find that the array still carries all the old values from the first
pass.

My question is, how can i make sure my array is empty before it goes
thru the loop again??
here is a bit of what i have for code: the array varies in size each
time.

Set rng = Range("D" & J + K, "N" & J + K)
count = 1

For Each c In rng


If (Not IsEmpty(c) And IsNumeric(c)) Then
Select Case c.Font.ColorIndex
Case xlAutomatic, 1
ReDim Preserve meanArray(1 To count)

meanArray(count) = c.Value
count = count + 1
End Select

thanks alot for everyones help.


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to

creating financial statements




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Clearing values automaticaly when different function selected Xman New Users to Excel 2 April 10th 10 02:51 AM
Clearing cells without clearing formulas marsjune68 Excel Discussion (Misc queries) 2 April 10th 09 07:39 PM
How to use values stored in a combo box control? Arlen Excel Discussion (Misc queries) 4 July 25th 08 09:34 PM
Array: Counting multiple values within array Trilux_nogo Excel Worksheet Functions 4 April 16th 07 03:12 AM
Clearing the Values in a Drop - Down List Sagu Excel Discussion (Misc queries) 4 March 31st 06 03:32 AM


All times are GMT +1. The time now is 11:00 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"