Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default command button help



M & E # QTY NAME FILLED NIS COMMENTS PRINT NIS
26-2911-3-0031 1 HOSE, CASE DRAIN PUMP ER10403



have spreadsheet setup like this.
i am trying to hide or unhide a command button in the print nis cell
by placing an "x" in the NIS cell

also when the command button is unhid i want to click it and open another
workbook print it and then close it
then gray out the command button

please help.

M & E # QTY NAME FILLED NIS COMMENTS PRINT NIS
26-2911-3-0031 1 HOSE, CASE DRAIN PUMP x ER10403 button


thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default command button help

Whether the following will work is dependant on whether I have interpreted
your question correctly.

There are 2 types of Command buttons. Forms control and ActiveX control. The
code requires the ActiveX control. In xl2007 select the button from the
ActiveX group. In earlier versions select from the Control Toolbox toolbar.

Right click on the worksheet tab name and copy the code into the VBA editor.
You will see comments re name of command button and also on how to obtain the
code to open, print and close the workbook. I have included a line to disable
the command button.

If you have problems then post the code you finish up with including any
error messages etc.

Private Sub Worksheet_Change(ByVal Target As Range)

'Edit E2 to the range where you place X
If Target = Range("E2") Then
If UCase(Range("E2")) = "X" Then
'Edit CommandButton1 in following lines _
to the name of your command button
Me.CommandButton1.Visible = True
Me.CommandButton1.Enabled = True
Else
Me.CommandButton1.Visible = False
End If
End If

End Sub

'Edit CommandButton1 to name of your command button.
Private Sub CommandButton1_Click()

'Record a macro to open the required workbook, _
print the required worksheets and close the _
workbook.

'Then edit Macro1 in the following line to _
match your recorded macro name. (It might _
not required changing.)

Call Macro1
Me.CommandButton1.Enabled = False

End Sub


--
Regards,

OssieMac


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default command button help

Work great thanks

but do have another question
can you use a command button to
close a document and bypass the save or not to save question
and not save?

"OssieMac" wrote in message
...
Whether the following will work is dependant on whether I have interpreted
your question correctly.

There are 2 types of Command buttons. Forms control and ActiveX control.
The
code requires the ActiveX control. In xl2007 select the button from the
ActiveX group. In earlier versions select from the Control Toolbox
toolbar.

Right click on the worksheet tab name and copy the code into the VBA
editor.
You will see comments re name of command button and also on how to obtain
the
code to open, print and close the workbook. I have included a line to
disable
the command button.

If you have problems then post the code you finish up with including any
error messages etc.

Private Sub Worksheet_Change(ByVal Target As Range)

'Edit E2 to the range where you place X
If Target = Range("E2") Then
If UCase(Range("E2")) = "X" Then
'Edit CommandButton1 in following lines _
to the name of your command button
Me.CommandButton1.Visible = True
Me.CommandButton1.Enabled = True
Else
Me.CommandButton1.Visible = False
End If
End If

End Sub

'Edit CommandButton1 to name of your command button.
Private Sub CommandButton1_Click()

'Record a macro to open the required workbook, _
print the required worksheets and close the _
workbook.

'Then edit Macro1 in the following line to _
match your recorded macro name. (It might _
not required changing.)

Call Macro1
Me.CommandButton1.Enabled = False

End Sub


--
Regards,

OssieMac




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default command button help


Private Sub CommandButton2_Click()
'Closes another open workbook without saving

Workbooks("Test.xls").Close SaveChanges:=False

End Sub

Private Sub CommandButton3_Click()
'Closes the workbook containing the _
macro code without saving

ThisWorkbook.Close SaveChanges:=False

End Sub

--
Regards,

OssieMac


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
print command from command button in userform causes double chart Mike Jamesson Excel Programming 5 August 11th 09 03:42 AM
BUG: print command from command button in userform causes double c Mike Jamesson Excel Programming 0 August 10th 09 04:19 PM
Deselect Command Button by Selecting another Command Button gmcnaugh[_2_] Excel Programming 3 September 2nd 08 05:59 PM
Wanting to Create A Command Button Command bumper338 Excel Programming 3 May 7th 07 06:53 PM
VB's Command Button vs Form's Command Button Ronald Dodge Excel Programming 3 May 24th 06 02:23 PM


All times are GMT +1. The time now is 08:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"