LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Naming variable range selected by cursor movement

following code via macro recorder is intended to create a named database
range "Format_all" via cursor movement selection and then to format for
printing uisng data sort commands. But I need to eliminate fixed range
definition since the number of rows of data needs to be able to change freely
with the cursor selection.

Can you help?


Sub Format_All()
'
' Format_All Macro
' Format All Records for Printing
'

'
Application.Goto Reference:="Format_Start"
Selection.End(xlDown).Select
Selection.End(xlToLeft).Select
Range("A1").Select
Range(Selection, Selection.End(xlUp)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveWorkbook.Names.Add Name:="FORMAT_ALL", RefersToR1C1:="r9c1:R936C43"
ActiveWorkbook.Names("Format_all").Comment = ""
ActiveWorkbook.Worksheets("ESTIMATE").Sort.SortFie lds.Clear
ActiveWorkbook.Worksheets("ESTIMATE").Sort.SortFie lds.Add Key:=Range( _
"SortKey"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("ESTIMATE").Sort.SortFie lds.Add Key:=Range( _
"Class"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("ESTIMATE").Sort.SortFie lds.Add Key:=Range( _
"Description"), SortOn:=xlSortOnValues, Order:=xlAscending,
DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("ESTIMATE").Sort
.SetRange Range("Format_all")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub


thanks!
 
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
how can I limit cursor movement within specified range in excel? slk0217 Excel Discussion (Misc queries) 2 January 5th 08 06:03 AM
excel limit data entry range, control cursor movement to 2 cols Bob Excel Programming 4 September 23rd 05 05:14 PM
Cursor Movement vs. Range Reference Jeff[_43_] Excel Programming 1 December 10th 04 05:31 PM
how to confine the range of movement of cursor starwil[_2_] Excel Programming 2 May 27th 04 10:16 AM
how to confine the range of movement of cursor starwil[_2_] Excel Programming 6 May 24th 04 03:38 PM


All times are GMT +1. The time now is 10:19 AM.

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"