RE: Prob with Var Data-types..

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Mourinho (Mourinho_at_discussions.microsoft.com)
Date: 10/28/04


Date: Thu, 28 Oct 2004 09:59:04 -0700

Thanks Stewart
ReDim...of course.

I managed to delete an important line in the code I pasted- here it is again.

I still cannot get the HderRows variable (in the 2nd part of the code) to
return a row or cell value however...I am not sure what to apply in terms of
var data-type and/or cell property (.Value?) for the loop to return a row or
cell for each HderRows variable. All my attempts are returning errors or
unwanted values.

M.

'Defines Number of Header Rows
NoHderRows = 1

Do Until IsEmpty(ActiveCell)
    ActiveCell.Offset(CntMon + 5, 0).Select
(MISSING) NoHderRows = NoHderRows + 1
Loop
    NoHderRows = NoHderRows - 1
    
'Defines HeaderRows
Range("B3").Select
    For j = 1 To NoHderRows
        HderRows(j) = ActiveCell.Select
        ActiveCell.Offset(CntMon + 5, 0).Select
    Next j

"Datasort" wrote:

> You have 2 problems:
>
> First is that the do while loop might possible expand past the array value.
>
> Secondly,
>
> you can use Dim HderRows() As String to set an unknown array size but you
> must at some point use the redim to reset the array size BEFORE you start
> using the array
>
> Good Luck,
>
> Stewart Rogers
>
> "Mourinho" wrote:
>
> > I have this macro to assign rows with data headers to the variable HderRows
> > - I want to return HderRows as a Row number or Cell though can't get it to
> > work..missing something here about Object variables or something.
> > - Not sure why Dim HderRows () doesn't allow empty parenthesis. Understand
> > this should give a variable array (though 15 is a reasonable max anyway).
> >
> > Thanks
> >
> > M.
> >
> > Dim HderRows(15) As String
> > NoHderRows = 1
> > Do Until IsEmpty(ActiveCell)
> > ActiveCell.Offset(CntMon + 5, 0).Select
> > Loop
> > NoHderRows = NoHderRows - 1
> >
> > 'Defines HeaderRows
> > Range("B3").Select
> > For j = 1 To NoHderRows
> > HderRows(j) = ActiveCell.Value
> > ActiveCell.Offset(CntMon + 5, 0).Select
> > Next j



Relevant Pages

  • RE: User List Box - List from Hidden range - VBA worng
    ... In your for loop, ... range is only 1 column wide this will be a single cell). ... Basic Editor type the word on it's own in lower case on a line and hit enter. ... in the array reference - and an array starts with element 0. ...
    (microsoft.public.excel.programming)
  • RE: User List Box - List from Hidden range - VBA worng
    ... In your for loop, ... range is only 1 column wide this will be a single cell). ... Basic Editor type the word on it's own in lower case on a line and hit enter. ... in the array reference - and an array starts with element 0. ...
    (microsoft.public.excel.programming)
  • Re: Do I need a two dimensional array for this?
    ... I think you can use the same array that you use for ICE. ... The new part will start a loop and look for IC100 and QA100 in the range. ... It will write PK100 to the cell and increment i by 1. ...
    (microsoft.public.excel.programming)
  • Re: Setting A variable name From Loop
    ... So the values are just a String in an array? ... To find the cell with the first of those values, ... Dim myVal() As Variant ... The Loop would only run until the List has run out of information (or ...
    (microsoft.public.excel.programming)
  • Re: Offset
    ... Loop Until IsEmpty) ... Tom Ogilvy ... I have a Header U1 some Text in U2, ... I would like to Goto U1 Then Find and select the last cell in column U that ...
    (microsoft.public.excel.programming)