+ Reply to Thread
Results 1 to 5 of 5

Trouble when trying to call a sub

  1. #1

    Trouble when trying to call a sub

    People, I'm trying to call a sub from a form, but the message "Sub or
    Function not defined" appears when compiled.

    That is the following code:

    Sub Macro1()




    For i = 3 To 100



    Set oBk = Workbooks.Open(link)

    iefile = ActiveWorkbook.Name
    Call HTMLText2_Click
    sdr = Cells(10, 1).Value
    Range(Cells(10, 2), Cells(10, 3)).Select
    Selection.Copy
    Range("J9").Select
    Selection.PasteSpecial Paste:=xlPasteValues
    cmt = Cells(9, 10).Value
    sdis = Cells(10, 5).Value
    Range(Cells(10, 6), Cells(10, 7)).Select
    Selection.Copy
    Range("J10").Select
    Selection.PasteSpecial Paste:=xlPasteValues
    audit = Cells(10, 10).Value
    Workbooks(iefile).Close (0)
    Cells(i, 12) = sdr
    Cells(i, 13) = cmt
    Cells(i, 14) = sdis
    Cells(i, 15) = audit
    End If

    Next i

    End Sub

    --

    Sub HTMLText2_Click()
    Cells(1, 10) = HTMLText2.Value
    End Sub

    --

    I tried to use the Call Method, and only writing the name of the sub in
    the code... But the error still appear.


    Somebody help meeeeeeeeeee....


  2. #2
    Edmund
    Guest

    Re: Trouble when trying to call a sub


    End If without If.

    Edmund

    <[email protected]> wrote in message
    news:[email protected]...
    > People, I'm trying to call a sub from a form, but the message "Sub or
    > Function not defined" appears when compiled.
    >
    > That is the following code:
    >
    > Sub Macro1()
    >
    >
    >
    >
    > For i = 3 To 100
    >
    >
    >
    > Set oBk = Workbooks.Open(link)
    >
    > iefile = ActiveWorkbook.Name
    > Call HTMLText2_Click
    > sdr = Cells(10, 1).Value
    > Range(Cells(10, 2), Cells(10, 3)).Select
    > Selection.Copy
    > Range("J9").Select
    > Selection.PasteSpecial Paste:=xlPasteValues
    > cmt = Cells(9, 10).Value
    > sdis = Cells(10, 5).Value
    > Range(Cells(10, 6), Cells(10, 7)).Select
    > Selection.Copy
    > Range("J10").Select
    > Selection.PasteSpecial Paste:=xlPasteValues
    > audit = Cells(10, 10).Value
    > Workbooks(iefile).Close (0)
    > Cells(i, 12) = sdr
    > Cells(i, 13) = cmt
    > Cells(i, 14) = sdis
    > Cells(i, 15) = audit
    > End If
    >
    > Next i
    >
    > End Sub
    >
    > --
    >
    > Sub HTMLText2_Click()
    > Cells(1, 10) = HTMLText2.Value
    > End Sub
    >
    > --
    >
    > I tried to use the Call Method, and only writing the name of the sub in
    > the code... But the error still appear.
    >
    >
    > Somebody help meeeeeeeeeee....
    >




  3. #3

    Re: Trouble when trying to call a sub

    No man, there is an If, but when I was copying the code, I deleted the
    if.

    The code is running perfect, only when I try to call the form method
    the error appears.


  4. #4
    Bob Phillips
    Guest

    Re: Trouble when trying to call a sub

    Are both macros in the same code module. If the Click code is in a sheet
    code module, you need to precede with the sheet codename.

    --

    HTH

    Bob Phillips

    (remove nothere from the email address if mailing direct)

    <[email protected]> wrote in message
    news:[email protected]...
    > People, I'm trying to call a sub from a form, but the message "Sub or
    > Function not defined" appears when compiled.
    >
    > That is the following code:
    >
    > Sub Macro1()
    >
    >
    >
    >
    > For i = 3 To 100
    >
    >
    >
    > Set oBk = Workbooks.Open(link)
    >
    > iefile = ActiveWorkbook.Name
    > Call HTMLText2_Click
    > sdr = Cells(10, 1).Value
    > Range(Cells(10, 2), Cells(10, 3)).Select
    > Selection.Copy
    > Range("J9").Select
    > Selection.PasteSpecial Paste:=xlPasteValues
    > cmt = Cells(9, 10).Value
    > sdis = Cells(10, 5).Value
    > Range(Cells(10, 6), Cells(10, 7)).Select
    > Selection.Copy
    > Range("J10").Select
    > Selection.PasteSpecial Paste:=xlPasteValues
    > audit = Cells(10, 10).Value
    > Workbooks(iefile).Close (0)
    > Cells(i, 12) = sdr
    > Cells(i, 13) = cmt
    > Cells(i, 14) = sdis
    > Cells(i, 15) = audit
    > End If
    >
    > Next i
    >
    > End Sub
    >
    > --
    >
    > Sub HTMLText2_Click()
    > Cells(1, 10) = HTMLText2.Value
    > End Sub
    >
    > --
    >
    > I tried to use the Call Method, and only writing the name of the sub in
    > the code... But the error still appear.
    >
    >
    > Somebody help meeeeeeeeeee....
    >




  5. #5
    josuegm
    Guest

    Re: Trouble when trying to call a sub

    Man, sorry... but how do I precede with the sheet codename? I didn't
    understand...


+ 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