Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default 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 .
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Reply
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
copy/pasting data into a worksheet and then sorting worksheet Pierrette T[_2_] Excel Programming 0 November 11th 09 03:23 AM
Sorting Master Worksheet to Regional Worksheet teapot10 Excel Worksheet Functions 3 April 14th 08 07:08 PM
Worksheet sorting medavino Excel Discussion (Misc queries) 0 May 16th 07 04:18 PM
Sorting a range on another worksheet without selecting the worksheet [email protected] Excel Programming 1 December 21st 06 11:06 PM
worksheet sorting sisco98 Excel Worksheet Functions 5 July 22nd 05 02:44 PM


All times are GMT +1. The time now is 07:40 AM.

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

About Us

"It's about Microsoft Excel"