Private subs

G

Guest

I have created the following private sub in my worksheet:

Private Sub CommandButton1_Click()
' Define a área de impressão
ActiveSheet.PivotTables("Pivot Table Show Price").PivotSelect _
"Produto[All]", xlLabelOnly, True
ActiveSheet.PageSetup.PrintArea = _
ActiveCell.CurrentRegion.Address
Range("A1").Select
End Sub

So, now I want to create a macro to do perform some actions (see below) and
to run this private sub as the last action of the macro below...how can I do
this?

Sub Copy_Log()
Application.Goto Reference:="Log"
Selection.Copy
Workbooks.Open Filename:="S:\Finance\Pricing\General\TimeTable1.xls"
Sheets("DB").Select
Application.Goto Reference:="Index1"
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=True
Range("A1").Select
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWindow.Close


End Sub
 
G

Guest

Are the two procedures in the same module, class or sheet. If not then you
can not reference the private sub from the other. That is the purpose of
private. If they are both in the same module then you can reference it by
adding it in. Since this is an event procedure take to code out of the
private sub and put it in a public sub. Reference the public sub from both
the on click and the other sub...

HTH...
 

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