Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Checking contents of arrays

I have a problem with checking the contents of an array in a loop. The array
looks originally like this:

Dim varWorksheetInfoArray(15) As Variant
varWorksheetInfoArray(0) = "Avkdata"
varWorksheetInfoArray(1) = "Date"
etc€¦

I then call another sub and send the array along:
Call chartMaker(varWorksheetInfoArray)

Private Sub chartMaker(ByRef varWorksheetInfoArray() As Variant)
Dim i, j, k As Integer
ReDim rng(1 To UBound(varWorksheetInfoArray)) As Range

I then put the info from the varWorksheetInfoArray and put it in a new
array. I do this because I need the addresses of the cells containing the
text the was defined in varWorksheetInfoArray.

Do While k < UBound(rng)
Set rng(k) =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(k),
LookIn:=xlValues)
k = k + 1
Loop

I then get some values for the integers i, j etc. and make some other stuff
that is not important here. The problem occurs in the following piece of code:
k = 2 'startvärde

Do While k < UBound(rng) - 1
If Not rng(k) Is Nothing Then
ActiveChart.SeriesCollection(k - 1).Values =
Sheets(varWorksheetInfoArray(0)).Range(rng(k).Offs et(i, 0).Address & ":" &
rng(k).Offset(j, 0).Address)
Else: End If
k = k + 1

Loop

The problem is that the varWorksheetInfoArray has to have a €śgeneral€ť
dimension. I use this array many times but sometimes I just need three spaces
and sometimes ten spaces in the array. Thus sometime some spaces will be
empty, or undefined. When declaring the contents of the array I write:
varWorksheetInfoArray(0) = "Avkdata"
varWorksheetInfoArray(3) = "Price"
but some spaces will not be mentioned e.g.
varWorksheetInfoArray(2) is never mentioned. I dont know what €śvalue€ť that
space gets. The problem is that when loop through the rng array I need to
check if there are contents in the spaces in the array. But it just pops out
of the loop as it is now if there is some space that does not have any
contents. If you know how to solve this please help me out. Thank you very
much!!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Checking contents of arrays

if not rng(k) is empty then

--
Regards,
Tom Ogilvy

"Bloomberg" wrote:

I have a problem with checking the contents of an array in a loop. The array
looks originally like this:

Dim varWorksheetInfoArray(15) As Variant
varWorksheetInfoArray(0) = "Avkdata"
varWorksheetInfoArray(1) = "Date"
etc€¦

I then call another sub and send the array along:
Call chartMaker(varWorksheetInfoArray)

Private Sub chartMaker(ByRef varWorksheetInfoArray() As Variant)
Dim i, j, k As Integer
ReDim rng(1 To UBound(varWorksheetInfoArray)) As Range

I then put the info from the varWorksheetInfoArray and put it in a new
array. I do this because I need the addresses of the cells containing the
text the was defined in varWorksheetInfoArray.

Do While k < UBound(rng)
Set rng(k) =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(k),
LookIn:=xlValues)
k = k + 1
Loop

I then get some values for the integers i, j etc. and make some other stuff
that is not important here. The problem occurs in the following piece of code:
k = 2 'startvärde

Do While k < UBound(rng) - 1
If Not rng(k) Is Nothing Then
ActiveChart.SeriesCollection(k - 1).Values =
Sheets(varWorksheetInfoArray(0)).Range(rng(k).Offs et(i, 0).Address & ":" &
rng(k).Offset(j, 0).Address)
Else: End If
k = k + 1

Loop

The problem is that the varWorksheetInfoArray has to have a €śgeneral€ť
dimension. I use this array many times but sometimes I just need three spaces
and sometimes ten spaces in the array. Thus sometime some spaces will be
empty, or undefined. When declaring the contents of the array I write:
varWorksheetInfoArray(0) = "Avkdata"
varWorksheetInfoArray(3) = "Price"
but some spaces will not be mentioned e.g.
varWorksheetInfoArray(2) is never mentioned. I dont know what €śvalue€ť that
space gets. The problem is that when loop through the rng array I need to
check if there are contents in the spaces in the array. But it just pops out
of the loop as it is now if there is some space that does not have any
contents. If you know how to solve this please help me out. Thank you very
much!!

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
checking if two arrays are equal Knox Excel Programming 3 June 1st 06 05:56 PM
checking a Cells contents Bob Kilmer Excel Programming 2 September 13th 04 06:41 AM
checking a Cells contents Don Lloyd Excel Programming 0 September 9th 04 10:52 AM
Checking contents Edgar Thoemmes Excel Programming 4 February 9th 04 02:01 AM
Checking contents Edgar Thoemmes[_2_] Excel Programming 5 February 3rd 04 02:56 PM


All times are GMT +1. The time now is 09:22 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"