LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Macro Help Needed - Added Info

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula needed: argument changes as more data is added BK Excel Worksheet Functions 9 March 12th 09 02:24 AM
How do I set up a chart that auto updates as new info is added? Alison Excel Discussion (Misc queries) 2 February 6th 09 02:35 AM
Sum a column correctly after more info is added by sorting Soulscream Excel Worksheet Functions 9 January 22nd 09 08:53 PM
How do i set Excel to record the date etc of info added arrivarob Excel Worksheet Functions 1 March 29th 07 02:23 PM
Inventory added sub needed David Excel Programming 4 March 29th 05 12:01 PM


All times are GMT +1. The time now is 04:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"