Newbie, I dont want macro to reference worksheet name
Can't test it on this machine, but you can try
ActiveSheet.Sort.SortFields.Clear
ActiveSheet.Sort.SortFields.Add _
Key:=Range("B1"), _
SortOn:=xlSortOnValues, -
Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveSheet.Sort
In article ,
Michael wrote:
THANKN YOU for your help.
I tried to do as you said but I get error cause I dont know the exact way to
do it.
here is an ex. that it makes.
ActiveWorkbook.Worksheets("EventQuery-2007-03-29-14-59-24(").Sort.SortFields.
_
Clear
ActiveWorkbook.Worksheets("EventQuery-2007-03-29-14-59-24(").Sort.SortFields.
_
Add Key:=Range("B1"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("EventQuery-2007-03-29-14-59-24(").Sort
"Gord Dibben" wrote:
ActiveWorkbook
ActiveSheet
ActiveCell
Make the required edits to get rid of hard-coded references.
Gord Dibben MS Excel MVP
On Thu, 29 Mar 2007 12:24:02 -0700, Michael
wrote:
2007 Excel, I am trying to create macros by recording my actions but when
I
do they dont work cause the name of the worksheet is different. Tried the
relative reference but doesnt help. Tried deleting the reference out of
macro
but doesnt work. Just want generic macro that will work on any file name
and
any worksheet name. Ex. even to sort when you select the page in upper
left.
|