Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 27 of 27

Thread: VBA Matrix Operations Help Needed.

  1. #21
    Is there a way for the array range to be dynamic … like Dim array(1 to N) Double N could be set differently in different parts of the code?

  2. #22
    Is there a way for the array range to be dynamic … like Dim array(1 to N) Double where N could be set differently in different parts of the code?

  3. #23
    Quote Originally Posted by Paul_Hossler View Post
    You Dim-ed Del1St and W1St as Variant, and plain variants don't take an Index (IZ)

    I did not see where Z1St was Dim-ed at all



                Del1St(IZ) = Del1  'Type Mismatch
                W1St(IZ) = W1     'Type Mismatch
                Z1St(IZ) = Z1       'Type Mismatch
    
    I'm guessing you wanted


    Dim Del1St(1 to 20) As Double Dim W11St(1 to 20) As Double Dim Z1St(1 to 20) As Double

  4. #24
    Paul ... please help me remember how to mark a topic “solved”

  5. #25
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    Above your first post, there's [Thread Tools] and an option is to mark [SOLVED]
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  6. #26
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    Quote Originally Posted by dennygibson View Post
    Is there a way for the array range to be dynamic … like Dim array(1 to N) Double where N could be set differently in different parts of the code?
    Yes

    Look in Help for "ReDim" and "Redim Preserve"

    However, I've found that most times it's not needed and can be designed around

    Some sample code


    Option Explicit
    
    Sub Arrays()
        Dim A(1 To 2) As Long   '   fixed
        Dim B() As Long         '   ReDim-able
        
        A(1) = 100
        A(2) = 200
        MsgBox A(1) & " -- " & A(2)
        
        ReDim B(1 To 3)
        B(1) = 1000
        B(2) = 2000
        B(3) = 3000
        MsgBox B(1) & " -- " & B(2) & " -- " & B(3)
        
        ReDim Preserve B(1 To 4)
        B(4) = 4000
        MsgBox B(1) & " -- " & B(2) & " -- " & B(3) & " -- " & B(4)
        
        Erase A
        MsgBox A(1) & " -- " & A(2)
        A(1) = 10000
        A(2) = 20000
        MsgBox A(1) & " -- " & A(2)
    End Sub
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  7. #27
    Paul ... thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •