![]() |
Private subs
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.x ls" 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 |
Private subs
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... "Flima" wrote: 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.x ls" 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 |
All times are GMT +1. The time now is 11:14 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com