View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Brad[_26_] Brad[_26_] is offline
external usenet poster
 
Posts: 10
Default Including tab name in absolute reference

Joel,

Thank you for your help. It gave me what I was looking for.

I understand the run time issues of the select method; however, editing the
code would take longer the than improvement in run time on most of my
macros. I will keep this in mind on the macros I use more than 25 times,
but typically I write macros for a project to update multiple workbooks
after the project has started. I typically have less than 20 workbooks on
which to run the macro, but want to be sure that I run it on the correct
sheet.

I also run the macro once on the workbooks I use as templates so I don't
need to run the macros in future projects. In other words, most of my
macros are made by using the recorder, edited as needed, and then deleted at
the end of the day. Editing to avoid the select method would not be
efficient for most of my macros, but I will review at the ones I keep long
term.

Thank you again. It was helpful.

Brad

Excel 2002 on XP Pro SP 3
Excel 2007 on Vista 64
"joel" wrote in message
...

The answer is "NOT TO USE the SELECT METHOD". In your code reference
each sheet by its object or Name. Don't use recorded macros without
eliminating all the select properties and activate properties (there are
only a few cases where this may not work).


Selection of TABS slows down the macro and can create errors like you
are finding out. Here are some examples of the correct method of
referencing objects


set bk = workbooks.open(Filename:=Book1.xls)

set sht = bk.sheets("sheet1")

for each sht in bk.sheets


set DataRange = sht.rangge("A1:B100")


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread:
http://www.thecodecage.com/forumz/sh...d.php?t=170049

Microsoft Office Help