+ Reply to Thread
Results 1 to 3 of 3

Using one button to make another visible

  1. #1
    Registered User
    Join Date
    01-09-2019
    Location
    Houston, TX
    MS-Off Ver
    365
    Posts
    1

    Using one button to make another visible

    I have a spreadsheet that is needed to track many approvals in different locations but all using the same macro so I have used the application.caller function to determine depending what button is pressed that specific cell will be edited:

    Sub Approval()
    BR = ActiveSheet.Buttons(Application.Caller).TopLeftCell.Row
    BC = ActiveSheet.Buttons(Application.Caller).TopLeftCell.Column
    Set WSHnet = CreateObject("WScript.Network")
    UserName = WSHnet.UserName
    UserDomain = WSHnet.UserDomain
    Set objUser = GetObject("WinNT: forwardslash forwardslash" & UserDomain & "/" & UserName & ",user")
    UserFullName = objUser.FullName
    UserId = Environ("UserName")
    valueAdd = "Approved By " & UserFullName & " (" & UserId & ")" & " on " & Date
    Cells(BR, BC).Value = valueAdd
    ActiveSheet.Buttons(Application.Caller).Visible = False
    End Sub

    After the approval button is pressed it records the user info in the cell and the button disappears. All of this is working perfectly.

    What I also need is in the adjacent cell of each approval button is a reset button that will clear the cell and make the approval button visible again. I have tried something like this:

    Sub Reset()
    BR = ActiveSheet.Buttons(Application.Caller).TopLeftCell.Row
    BC = ActiveSheet.Buttons(Application.Caller).TopLeftCell.Column
    For Each Cell In Range(Cells(BR, BC - 2), Cells(BR, BC - 1))
    ActiveSheet.Buttons().Visible = True
    Cells(BR, BC - 1) = ""
    Next Cell
    End Sub

    The red part is what is not working for me. It is making all the approval buttons on the sheet visible when I only want the button in the adjacent cell to reappear. (I am using the range of Cells(BR, BC - 2), Cells(BR, BC - 1) since I have a couple merged cells that the approval is recorded in).

    I cant realistically use button names as since I have so many approvals to track it would require a distinct macro for each one, wouldn't it?

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

    Re: Using one button to make another visible

    You can edit your original post and add code tags, check out the pic.
    -
    -
    AA CodeTags.jpg

  3. #3
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,153

    Re: Using one button to make another visible

    Quote Originally Posted by Voltas View Post
    ... so I have used the application.caller function to determine depending what button is pressed ...
    Instead of using "Application.Caller", give your buttons unique names and refer to these buttons through these names.

    Quote Originally Posted by Voltas View Post
    ... I have tried something like this:
    Please Login or Register  to view this content.
    Don't use the name "Reset" for the name of the Sub, variable name, etc. => "Reset" - Statement - Closes all disk files opened using the Open statement

    Upload any example workbook (but take care of the confidentiality of your data).

+ 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] Not able to make DTPicker visible again after clicking button
    By jeroen78 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-29-2016, 09:56 AM
  2. a macro has to make visible a new macro-button
    By Xavier Derille in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-16-2015, 03:15 PM
  3. Make macro button visible/invisible as per user name
    By nayanthara in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-15-2014, 03:46 AM
  4. Make a Command Button Visible from another Command Button
    By trevor2524 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-13-2014, 10:11 AM
  5. [SOLVED] make window visible again
    By jed38 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-09-2013, 09:08 AM
  6. [SOLVED] All worksheets are not visible. Can't make them visible.
    By verdugan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-21-2012, 01:19 PM
  7. How do I make a command button invisible or visible?
    By Mandora in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-18-2005, 10:06 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