Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default Newbie, I dont want macro to reference worksheet name

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Newbie, I dont want macro to reference worksheet name

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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default Newbie, I dont want macro to reference worksheet name

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.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 182
Default Newbie, I dont want macro to reference worksheet name

It means you can not use special name of :
Cell, Sheet, Workbook but you have to set a variable for them in order to
use them unabsolute, just like:

Set Wk = ActiveSheet or Set Wk = Sheets("sheetname") etc...

--

Regards,

Halim


"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.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default Newbie, I dont want macro to reference worksheet name

I tired all the suggestions and still cant get it to work.
I tried the below but cant figure out the right way to use the variable of
Wk with out error.
I know its probably me being obtuse but can someone give me an example based
on this (the excel help stinks)


ActiveWorkbook.Worksheets("EventQuery-2007-03-29-14-59-24(").Sort.SortFields.
_
Add Key:=Range("B1"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
THANKS

"Halim" wrote:

It means you can not use special name of :
Cell, Sheet, Workbook but you have to set a variable for them in order to
use them unabsolute, just like:

Set Wk = ActiveSheet or Set Wk = Sheets("sheetname") etc...

--

Regards,

Halim


"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.



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
How do you get a macro to reference the worksheet it is being run Michelle D[_2_] Excel Discussion (Misc queries) 2 August 11th 09 10:17 AM
Newbie Cell Reference Question... UncleRemus New Users to Excel 2 October 30th 05 12:02 PM
Newbie vba - How do I reference cells in another workbook Ian[_10_] Excel Programming 3 June 8th 04 04:30 AM
Newbie help with cell reference carlab68 Excel Programming 4 December 9th 03 09:58 PM
Newbie question on cell reference 2 Mfaces Excel Programming 5 December 9th 03 07:58 PM


All times are GMT +1. The time now is 08:49 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"