+ Reply to Thread
Results 1 to 79 of 79

Do's and Don'ts So Others Won't

Hybrid View

  1. #1
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,040

    Re: Do's and Don'ts So Others Won't

    No it's syntax not style. Try it with an object variable.
    For example:

    Sub StopUsingParentheses()
        Dim rngTest As Range
        Dim x As Long, y As Long
        
        Set rngTest = Range("A1")
        ' oops!
        macro1 (rngTest)
        
        x = 4
        y = 5
        
        ' this won't even compile (so commented out)
        ' macro2 (x, y)
        
        ' and this just seems weird:
        macro2 (x), (y)
        
        ' but you can do:
        Call macro1(rngTest)
        Call macro2(x, y)
        
    End Sub
    Sub macro1(rng As Range)
        MsgBox rng.Address
    End Sub
    Sub macro2(var1, var2)
        MsgBox "Var 1 is: " & var1 & "; var2 is: " & var2
    End Sub
    Last edited by romperstomper; 09-10-2010 at 04:10 AM. Reason: add examples.
    Everyone who confuses correlation and causation ends up dead.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1