Function or VBA

A

AFJr

Hi,

Our company has a "Contract Review" form made up of 5 sheets. There are
certain situations when we will want 2 of the sheets to be included in our
quotation package to the customer. These 2 sheets contain the specifications
the RFQ was generated to.

My thought is to put a button on the individual sheets in the Contract
Review form. This will enable the estimator to click the button and insert
the sheets into the "Quotation" form.

Will this be easier to do via FUNCTIONS or VBA?

I am currently taking myself through Excel Programming Weekend Crash Cousre.
My experience with programming VBA is novice at best. I've written programs
for PLC's using ladder logic and also statement list. Just wondering, the
learning curve for VBA seems like it might be a while before I can accomplish
what I want to do with this.
 
I

iliace

Following assumptions:
* You are running a single instance of Excel (usually this is the
case)
* Your Quotations workbook is in a file called Quotations.xls
* You want the Active Sheet to be copied after the first worksheet in
Quotations.xls

The following sub, when assigned to your command button, will copy the
active sheet (on which the button is located, presumably) will be
copied. If Quotations.xls is not open, an error message is displayed.

Private Sub Button1_Click()
Dim wsh As Excel.Worksheet

Set wsh = Application.ActiveSheet

On Error Resume Next
wsh.Copy
After:=Application.Workbooks("Quotations.xls").Worksheets(1)
If Err.Number <> 0 Then
Call MsgBox("Error copying worksheet")
End If
On Error Goto 0
End Sub
 
I

iliace

Additionally, if you want the button to not be in your quotations
worksheet, and assuming there's only one button on it, you can use
this code:

Application.Workbooks("Quotations.xls").Worksheets(wsh.Name).Buttons(1).Delete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top