Hide/Unhide Command Button with save file option

malaya tigre

New Member
Joined
Apr 6, 2017
Messages
12
Hello...
I wish to have a command button that can hide/unhide with various safe file option based on drop down list value in G6. Here is a table:


<hide command="" button=""><unhide command="" button="" and="" save="" file="" only=""><unhide command="" button="" and="" save="" &="" close="" file="" immediately=""><unhide command="" button="" and="" save="" &="" close="" file="" immediately="">C2 : Open (hide Command Button)
C3 : In Progress (unhide Command Button and save file only)
C4 : Cancel (unhide Command Button and save & close file immediately)
C5 : Close (unhide Command Button and save & close file immediately)
G6 : Drop Down List box


Appreciates the helps. TQ.</unhide></unhide></unhide></hide>
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Since nobody willing to solve my question, here is my answer for my own question that I have figured it out for whom looking for an answer on the same question.I added an extra code for create filename based on B6 & E6 value. Take note that " " in >newFile = " " & fName & " " & vName< was purposely added for make a space in filename. I am glad to share the code here:



Private Sub CommandButton1_Click()
Dim newFile As String, fName As String, vName As String
fName = Range("B6").Value
vName = Range("E6").Value
tSave = Range("G6").Value
newFile = " " & fName & " " & vName
If tSave = "In Progress" Then
ThisWorkbook.SaveAs "Z:\TRAINING" & Format(Date, "ddmmyyyy") & newFile
Else
ThisWorkbook.SaveAs "Z:\TRAINING" & Format(Date, "ddmmyyyy") & newFile
ThisWorkbook.SaveAs
ThisWorkbook.Close
End If
End Sub
-------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
With Me
If .Range("G6").Value = "Open" Then
.CommandButton1.Visible = False
Else
.CommandButton1.Visible = True
End If
End With
End Sub
------------------------------
Private Sub Worksheet_Activate()
Application.EnableEvents = False
With Me
.CommandButton1.Visible = True
.Range("G6").Value = 1
End With
Application.EnableEvents = True
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,558
Messages
6,125,511
Members
449,236
Latest member
Afua

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top