Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Gavin
The following code would be one way of doing what you want, add three buttons to sheet1 (Production) then past this code in the sheet1 module. Each button will pass a sheet name to the WkSheet variable and from there it will call the sub SortAndPrint, this should work fine providing you are sorting the same range and printing the same print area for on each sheet. Option Explicit Dim WkSheet As Worksheet Private Sub CommandButton1_Click() Set WkSheet = Worksheets("Invoice") 'set worksheet SortAndPrint 'call SortAndPrint Sub End Sub Private Sub CommandButton2_Click() Set WkSheet = Worksheets("Order") SortAndPrint End Sub Private Sub CommandButton3_Click() Set WkSheet = Worksheets("Delivery Note") SortAndPrint End Sub Sub SortAndPrint() With WkSheet 'set the worksheet to use With .Range("C8:C58") 'set the range to sort .Sort key1:=WkSheet.Range("C8"), order1:=xlAscending, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal 'sort the range ascending End With .PageSetup.PrintArea = "$B$2:$M$58" 'set print range .PrintOut 'print End With End Sub Hope this helps you out S |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Formula needed: argument changes as more data is added | Excel Worksheet Functions | |||
How do I set up a chart that auto updates as new info is added? | Excel Discussion (Misc queries) | |||
Sum a column correctly after more info is added by sorting | Excel Worksheet Functions | |||
How do i set Excel to record the date etc of info added | Excel Worksheet Functions | |||
Inventory added sub needed | Excel Programming |