+ Reply to Thread
Results 1 to 12 of 12

1 pushbutton , running 2 different sunroutines ( 1 consequtive number, 2 send email)

  1. #1
    Registered User
    Join Date
    04-04-2013
    Location
    Northampton
    MS-Off Ver
    Excel 2010
    Posts
    40

    1 pushbutton , running 2 different sunroutines ( 1 consequtive number, 2 send email)

    Good morning,
    I am trying to get a single pushbutton on a form to increment cell d5 by one and also send an email with just 1 click
    Sub roundedRectangle1_click()
    sheet1.Range("E6"),Value=Sheet1.Range("e6").Value+1
    End Sub
    Sub rounded Rectangle1_Click()
    Active WorkBook.SendMail Recipients:="email address", subject"Form No.1"
    End Sub

    But it only seems to run 1 routine only?

    Any help greatly appreciated please.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Try this.
    Please Login or Register  to view this content.
    PS Can you edit your post to add code tags?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    04-04-2013
    Location
    Northampton
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: 1 pushbutton , running 2 different sunroutines ( 1 consequtive number, 2 send email)

    Thank you,
    but everytime I try to run this it sends an error message and highlights .Sheets
    error message reads "compile error"
    invalid use of property?

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: 1 pushbutton , running 2 different sunroutines ( 1 consequtive number, 2 send email)

    Sheets isn't in the code.

  5. #5
    Registered User
    Join Date
    04-04-2013
    Location
    Northampton
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: 1 pushbutton , running 2 different sunroutines ( 1 consequtive number, 2 send email)

    Hi Norie,
    Sorry typing error
    error message reads ""compile error" invalid use of property? and highlights on the second line,first .Range

    Sub roundedRectangle4_Click()
    ActiveWorkbook.SendMail Recipients:="[email protected]", Subject:="Northampton Event"
    Sheet1.Range ("E6"), Value = Sheet1.Range("E6").Value + 1

    End Sub

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: 1 pushbutton , running 2 different sunroutines ( 1 consequtive number, 2 send email)

    Do you have a worksheet with the codename Sheet1?

    The codename is what you see in the Project Explorer next to the sheet, the tab name is in brackets after it.

    ProjExplorerTabCodeNames.JPG

  7. #7
    Registered User
    Join Date
    04-04-2013
    Location
    Northampton
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: 1 pushbutton , running 2 different sunroutines ( 1 consequtive number, 2 send email)

    Yes, it is called Sheet1 at the moment

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: 1 pushbutton , running 2 different sunroutines ( 1 consequtive number, 2 send email)

    Actually there are errors in the code which I didn't see straight off because you didn't use code tags.

    This should run.
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-04-2013
    Location
    Northampton
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: 1 pushbutton , running 2 different sunroutines ( 1 consequtive number, 2 send email)

    hi norie,thanks for that, the error does not appear any more, but it only sends email and does not count up?

  10. #10
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: 1 pushbutton , running 2 different sunroutines ( 1 consequtive number, 2 send email)

    the code works fain for me...
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  11. #11
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: 1 pushbutton , running 2 different sunroutines ( 1 consequtive number, 2 send email)

    Robbosan

    Can you please add code tags?

  12. #12
    Registered User
    Join Date
    04-04-2013
    Location
    Northampton
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: 1 pushbutton , running 2 different sunroutines ( 1 consequtive number, 2 send email)

    Hi Norie,thank you for your help, I cut and pasted your code and it works. Many thanks

    Robbosan

+ 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