I would like to include a button on a worksheet that when clicked will save
the worksheet as "purchase order" plus a number that is entered in a cell on
the worksheet.
How would I go about this?
I would like to include a button on a worksheet that when clicked will save
the worksheet as "purchase order" plus a number that is entered in a cell on
the worksheet.
How would I go about this?
1. Copy the code below:
Dim sPath As String
sPath = "C:\Documents and Settings\jmorin\Desktop\"
ActiveWorkbook.SaveAs Filename:=sPath & _
"Purchase Order " & Range("A1").Value & ".xls"
2. Go to View > Toolbars and select "Control Toolbox"
3. Click on "Command Button" and draw a button on your
worksheet.
4. Right-click and go to "View Code".
5. Paste in the code from step 1.
6. Press ALT+Q to go back to Excel.
7. Press the "Exit Design Mode" the Control Toolbox
toolbar.
The code is set up to look for a PO# in A1. Change the
path to suit your needs.
HTH
Jason
Atlanta, GA
>-----Original Message-----
>I would like to include a button on a worksheet that
when clicked will save
>the worksheet as "purchase order" plus a number that is
entered in a cell on
>the worksheet.
>
>How would I go about this?
>.
>
hi,
Put this in the button's code module
Sub commandbutton1_click()
Dim n As Range
Set n = Range("A1")
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:= _
"H:\CodeStuff\PO" & n & ".xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:= _
"", ReadOnlyRecommended:=False _
, CreateBackup:=False
Workbooks.Open Filename:="H:\CodeStuff\POtest.xls"
ActiveWindow.ActivateNext
ActiveWorkbook.Close
Application.DisplayAlerts = True
End Sub
>-----Original Message-----
>I would like to include a button on a worksheet that when
clicked will save
>the worksheet as "purchase order" plus a number that is
entered in a cell on
>the worksheet.
>
>How would I go about this?
>.
>
assign this macro to your button:
ActiveWorkbook.SaveAs (["purchaseorder" & A2])
End Sub
assuming that A2 is the cell containing the invoice number. The brackets are required inside the parenthesis.
HTH
Bruce
The older I get, the better I used to be.
USA
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks