Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 18
Question Coding Equivalent of CRL-A?

When in a worksheet I can manually select all cells by doing a control-A is there an equivalent I can use when coding?

I tried recording a macro and it just enters the particular range that was selected so is not dynamic in the way control-A is.

I am trying to do this as a precondition before doing a sort on all the data.
  #2   Report Post  
Junior Member
 
Posts: 18
Default

Quote:
Originally Posted by Caveman1957 View Post
When in a worksheet I can manually select all cells by doing a control-A is there an equivalent I can use when coding?

I tried recording a macro and it just enters the particular range that was selected so is not dynamic in the way control-A is.

I am trying to do this as a precondition before doing a sort on all the data.
I have come up with this code below but now am having a problem with what to put in the .SetRange to use column A in the UsedRange selection.

ActiveWorkbook.Worksheets("SS").Sort.SortFields.Cl ear
ActiveWorkbook.Worksheets("SS").Sort.SortFields.Ad d Key:=Sheet8.UsedRange, _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("SS").Sort
.SetRange Range(?????????)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
  #3   Report Post  
Junior Member
 
Posts: 18
Default

Quote:
Originally Posted by Caveman1957 View Post
I have come up with this code below but now am having a problem with what to put in the .SetRange to use column A in the UsedRange selection.

ActiveWorkbook.Worksheets("SS").Sort.SortFields.Cl ear
ActiveWorkbook.Worksheets("SS").Sort.SortFields.Ad d Key:=Sheet8.UsedRange, _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("SS").Sort
.SetRange Range(?????????)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Turned out I had the ranges back to front in my mind :P

Code works if set as follows

ActiveWorkbook.Worksheets("SS").Sort.SortFields.Cl ear
ActiveWorkbook.Worksheets("SS").Sort.SortFields.Ad d Key:=Range("A:A"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("SS").Sort
.SetRange Sheet8.UsedRange
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

Hope this helps someone else save some pain
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Coding Equivalent of CRL-A?

Hi,

Am Wed, 19 Sep 2012 09:25:55 +0000 schrieb Caveman1957:

When in a worksheet I can manually select all cells by doing a control-A
is there an equivalent I can use when coding?


try:
ActiveSheet.UsedRange.Select


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 151
Default Coding Equivalent of CRL-A?

On 19/09/2012 11:53 PM, Claus Busch wrote:
Hi,

Am Wed, 19 Sep 2012 09:25:55 +0000 schrieb Caveman1957:

When in a worksheet I can manually select all cells by doing a control-A
is there an equivalent I can use when coding?


try:
ActiveSheet.UsedRange.Select


Regards
Claus Busch


Try:

Cells.Select

HTH
Mick.
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
VBA equivalent for XLL? Paul Schrum Excel Programming 1 August 4th 10 10:59 PM
Left() Need the equivalent of this Presto Excel Programming 5 December 4th 08 01:40 AM
"=ROW()-1" type of coding doesn't appear in a filter / is there coding that does? StargateFan[_3_] Excel Programming 10 October 6th 05 01:18 PM
Implant macro coding into ASP coding Sam yong Excel Programming 5 September 15th 05 10:37 AM
Equivalent Of VAL davidm Excel Programming 4 July 27th 05 06:22 PM


All times are GMT +1. The time now is 11:58 PM.

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"