+ Reply to Thread
Results 1 to 5 of 5

Run Macro, but don't select button

Hybrid View

  1. #1
    Registered User
    Join Date
    07-09-2008
    Location
    UK
    Posts
    3

    Run Macro, but don't select button

    I have created a macro that I attached to an autoshape.

    The macro is running fine, but my issue is with the behaviour.

    When I click on the button it runs the macro and also selects the shape which it would do normally if there were no macro attached.

    I want it to run the macro but not select the button.

    Is this possible? I'm using Excel 2007 if this helps.

    Thanks in advance,

    Matt

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Post the code. Please remember to wrap code as per forum rules below

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    07-09-2008
    Location
    UK
    Posts
    3
    Thanks for the reply.

    Here is the code:

    Sub bandwidth_on()
      Range("F7").Select
      ActiveCell.FormulaR1C1 = Range("F7") + "205"
      ActiveSheet.Shapes("bandwidth_toggle").Select
      ActiveSheet.Shapes("bandwidth_toggle").TextFrame.Characters.Text = "Toggle Off"
      Selection.OnAction = "bandwidth_off"
    End Sub
    Sub bandwidth_off()
      Range("F7").Select
      ActiveCell.FormulaR1C1 = Range("F7") - "205"
      ActiveSheet.Shapes("bandwidth_toggle").Select
      ActiveSheet.Shapes("bandwidth_toggle").TextFrame.Characters.Text = "Toggle On"
      Selection.OnAction = "bandwidth_on"
    End Sub

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Removing this line won't select the shape

    ActiveSheet.Shapes("bandwidth_toggle").Select
    HTH

    VBA Noob

  5. #5
    Registered User
    Join Date
    07-09-2008
    Location
    UK
    Posts
    3
    Thanks a lot!

+ 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