Thread: macro confusion
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default macro confusion

dim wks as worksheet
for each wks in activeworkbook.worksheets
wks.range("A1").value = "hi"
wks.range("b1").clearcontents
next wks

Make sure you qualify each range (or object or property or method) with "wks.".

scott wrote:

I am trying to create a macro that will perform the same function on
different tabs in a workbook, but whenever i try to run the macro for various
tabs, the macro defaults to the original tab that the macro was created in
and I end up getting an error message with options to end, debug, or cancel.
does anyone have suggestions to how i can fix this?


--

Dave Peterson