+ Reply to Thread
Results 1 to 3 of 3

Creating a button to run the macro

  1. #1
    Forum Contributor
    Join Date
    02-16-2012
    Location
    Denmark
    MS-Off Ver
    O365
    Posts
    256

    Creating a button to run the macro

    Hi. I am basic excel user so I hope you can help me.
    I found this macro online and it works perfectly in my needs.
    This macro will give the path for a link but when I run it, I need to click Alt F11+ F5
    I want to have a button on the sheet so user will just click it and run automatically.


    Here is the macro:


    Function GetURL(cell As Range, _
    Optional default_value As Variant)
    'Lists the Hyperlink Address for a Given Cell
    'If cell does not contain a hyperlink, return default_value
    If (cell.Range("A1").Hyperlinks.Count <> 1) Then
    GetURL = default_value
    Else
    GetURL = cell.Range("A1").Hyperlinks(1).Address & "#" & cell.Range("A1").Hyperlinks(1).SubAddress
    End If
    End Function
    Attached Files Attached Files

  2. #2
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Creating a button to run the macro

    Open the developer tag in the excel ribbon and create a button. With the button created right click and assign macro to the button when clicked.

    click the button in attached workbook

    close messgae box and press Ctrl F11 to see where to write your macro...
    Attached Files Attached Files
    Last edited by nigelog; 12-21-2016 at 09:38 AM.

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,474

    Re: Creating a button to run the macro

    It most likely is not the function but the sub you need to edit.
    Try this:
    Please Login or Register  to view this content.
    Add any shape to the sheet, right click and select Assign macro, to assign the macro to the shape.
    Last edited by davesexcel; 12-21-2016 at 09:38 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Help creating a macro button
    By glenlaw in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-15-2013, 12:10 AM
  2. [SOLVED] Creating a macro button with VBA
    By amotto11 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-15-2012, 12:50 PM
  3. VBA - Help creating a Macro for a button
    By JukeBoxHero in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-01-2012, 07:47 AM
  4. VBA - Help creating a Macro for a button
    By JukeBoxHero in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-11-2012, 07:53 AM
  5. Need Help creating a Macro with a Button
    By nn9955 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-30-2009, 03:24 PM
  6. Creating a Macro Button
    By Newton1234 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-12-2008, 11:46 AM
  7. Help Creating a Button through a Macro
    By Caligula in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-31-2007, 06:20 PM
  8. Creating a macro which presses a button containing a recorded macro
    By petros89 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-05-2005, 10:05 AM

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