Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Changing one range on multiple sheets.

There is a point in my code where I would like to reset the same range on
several worksheets to empty. Is there a way to do this without writing a
line of code for each sheet?

It looks like this right now:

MySheet1.Range("C3") = ""
MySheet2.Range("C3") = ""
MySheet2.Range("C3") = ""
etc...

TIA

Mike-hime


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 691
Default Changing one range on multiple sheets.

Hi Mike,
Since you are in programming and you have to process each
sheet separately in VBA unlike grouped sheets outside of programming.

If the sheet are grouped you can process the grouped worksheets
with programming without knowing the names of the sheets.
the insert rows example in
http://www.mvps.org/dmcritchie/excel/insrtrow.htm
where Gary L. Brown, included a revision to my macro to process
Grouped sheets

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Mike-hime" wrote in message ...
There is a point in my code where I would like to reset the same range on
several worksheets to empty. Is there a way to do this without writing a
line of code for each sheet?

It looks like this right now:

MySheet1.Range("C3") = ""
MySheet2.Range("C3") = ""
MySheet2.Range("C3") = ""
etc...

TIA

Mike-hime




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Changing one range on multiple sheets.

Mike,

You could do something like this:

Sub test()

Dim ws As Worksheet

For Each ws In ActiveWorkbook.Worksheets(Array("MySheet1", "MySheet2",
"MySheet3"))
ws.Range("C3") = ""
Next ws

End Sub

hth,

Doug

"Mike-hime" wrote in message
...
There is a point in my code where I would like to reset the same range on
several worksheets to empty. Is there a way to do this without writing a
line of code for each sheet?

It looks like this right now:

MySheet1.Range("C3") = ""
MySheet2.Range("C3") = ""
MySheet2.Range("C3") = ""
etc...

TIA

Mike-hime




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Changing one range on multiple sheets.

If anyone was curious, a friend of mine found this method, using an array
and the FillAcrossSheets function:

MySheet1.Range("C3") = ""
MySheets = Array("Sheet1", "Sheet2", Sheet3",etc...)
Sheets(MySheets).FillAcrossSheets Range:=MySheet1.Range("C3")

This copies range C3 on the specified sheet and pastes it into the same
range on all the sheets in the array. It's handy! And no grouping involved
:)
But thx for the help anyway David, it's always appreciated.

-Mike-hime



"David McRitchie" wrote in message
...
Hi Mike,
Since you are in programming and you have to process each
sheet separately in VBA unlike grouped sheets outside of programming.

If the sheet are grouped you can process the grouped worksheets
with programming without knowing the names of the sheets.
the insert rows example in
http://www.mvps.org/dmcritchie/excel/insrtrow.htm
where Gary L. Brown, included a revision to my macro to process
Grouped sheets

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Mike-hime" wrote in message

...
There is a point in my code where I would like to reset the same range

on
several worksheets to empty. Is there a way to do this without writing a
line of code for each sheet?

It looks like this right now:

MySheet1.Range("C3") = ""
MySheet2.Range("C3") = ""
MySheet2.Range("C3") = ""
etc...

TIA

Mike-hime






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
Change Header on Multiple Sheets without Changing Other Formatting David Excel Discussion (Misc queries) 1 April 22nd 10 12:51 AM
Changing dates on multiple sheets andyco11 New Users to Excel 3 March 1st 07 07:11 PM
Want to use a range name on multiple sheets Shelter Pat Excel Discussion (Misc queries) 1 April 13th 06 03:30 PM
Sum a range across multiple sheets CarlosAntenna Excel Worksheet Functions 4 October 29th 04 12:22 PM
Changing the value in multiple sheets without selecting those sheets herm Excel Programming 3 October 14th 03 03:50 PM


All times are GMT +1. The time now is 04:54 PM.

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"