+ Reply to Thread
Results 1 to 6 of 6

Thread: Can't execute a macro whit text inside procedure header's "()" *Help*

  1. #1
    Registered User
    Join Date
    01-24-2012
    Location
    Lund, Sweden
    MS-Off Ver
    Excel 2003
    Posts
    3

    Can't execute a macro whit text inside procedure header's "()" *Help*

    If I try to execute a macro whit the procedure header being like this: Sub test (Byval Target As Range)
    it doesn't work, instead a new window called Macros comes up.
    I have tried older codes that I have saved in a .txt and that I know worked befor but it's still the same problem.
    It is not a problem when im trying to run macros like: Sub test()

    Sub test() 'Works
    Sub test (Byval Target As Range) 'Doesn't Work

    I am new to VBA and fairly new to Excel tbh, so i did not know where to turn.
    Last edited by Timestamp; 01-24-2012 at 05:57 AM.

  2. #2
    Valued Forum Contributor Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds/Sheffield, England
    MS-Off Ver
    Excel 2003
    Posts
    1,031

    Re: Can't execute a macro whit text inside procedure header's "()" *Help*

    do you mean like this?
    Sub Test()
    rangeTest Sheet1.Cells(2, 1)
    End Sub
    Sub rangeTest(ByRef rng As Range)
    Dim o As Range
    For Each o In rng
        MsgBox o.value
    Next
    End Sub
    Click the * below to say thanks

    Girls sleep with guys who use photoshop, but marry the ones who work with Excel

    Corduroy
    pillows: They're making headlines!

    Did you mean: recursion
    http://www.google.com/search?hl=en&q=recursion

  3. #3
    Valued Forum Contributor OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,647

    Re: Can't execute a macro whit text inside procedure header's "()" *Help*

    You cannot run a macro that requires a range argument from the macros dialog, if that is what you are attempting, because you have no way to pass that range to it from the dialog.
    Good luck.

  4. #4
    Registered User
    Join Date
    01-24-2012
    Location
    Lund, Sweden
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Can't execute a macro whit text inside procedure header's "()" *Help*

    What I mean is, if I do a macro like this:

    Private sub Worksheets_change(ByVal Target As range)
    Application.EnableEvents = False
    Range("A1").Value = Target.Value
    Application.EnableEvents = True

    or

    Function nExists(FindName As string) As boolean
    Dim Rng as Range
    Dim myName as String
    On Error Resume Next
    myName = ActiveWorkbook.Names(FindName).Name
    If Err.Number = 0 then
    NameExists = True
    Else
    NameExists = False
    End If
    End Function

    I Can't write any code that needs text inside the "()".
    Hope you understand, dont know how else to explain it.

  5. #5
    Valued Forum Contributor Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds/Sheffield, England
    MS-Off Ver
    Excel 2003
    Posts
    1,031

    Re: Can't execute a macro whit text inside procedure header's "()" *Help*

    How are you trying to call/execute these macros?
    Click the * below to say thanks

    Girls sleep with guys who use photoshop, but marry the ones who work with Excel

    Corduroy
    pillows: They're making headlines!

    Did you mean: recursion
    http://www.google.com/search?hl=en&q=recursion

  6. #6
    Registered User
    Join Date
    01-24-2012
    Location
    Lund, Sweden
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Can't execute a macro whit text inside procedure header's "()" *Help*

    Yee thanks Kyle123, thats it.
    The memory is good but short.

    Here i been spaming F5

+ 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.2.0