![]() |
Sorting one worksheet from another worksheet
I am wanting to sort data in a worksheet from a command button on a different
worksheet. I want the focus to stay (or at least return) to the worksheet containing the command button. Is this even possible? If so, could someone supply a sample of code? Both worksheets are in the same workbook. Using excel 2003 . |
Sorting one worksheet from another worksheet
Yes. The trick is to not select the other sheet.
Option Explicit Private Sub CommandButton1_Click() Dim wks As Worksheet Dim myRng As Range Set wks = Me.Parent.Worksheets("Sheet2") 'some other sheet With wks Set myRng = .Range("A1:x99") 'some range End With With myRng .Cells.Sort _ key1:=.Columns(1), order1:=xlAscending, _ key2:=.Columns(3), order1:=xlAscending, _ header:=xlYes End With End Sub Phyllis wrote: I am wanting to sort data in a worksheet from a command button on a different worksheet. I want the focus to stay (or at least return) to the worksheet containing the command button. Is this even possible? If so, could someone supply a sample of code? Both worksheets are in the same workbook. Using excel 2003 . -- Dave Peterson |
Sorting one worksheet from another worksheet
Check your other post.
Phyllis wrote: I am wanting to sort data in a worksheet from a command button on a different worksheet. I want the focus to stay (or at least return) to the worksheet containing the command button. Is this even possible? If so, could someone supply a sample of code? Both worksheets are in the same workbook. Using excel 2003 . -- Dave Peterson |
Sorting one worksheet from another worksheet
Oops. I must have been seeing double!
Dave Peterson wrote: Check your other post. Phyllis wrote: I am wanting to sort data in a worksheet from a command button on a different worksheet. I want the focus to stay (or at least return) to the worksheet containing the command button. Is this even possible? If so, could someone supply a sample of code? Both worksheets are in the same workbook. Using excel 2003 . -- Dave Peterson -- Dave Peterson |
All times are GMT +1. The time now is 11:19 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com