Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 419
Default Programmatically changing values on grouped sheets

Hello all,

I have 2 sheets that are identical in format, layout, formulas. The only
difference is some cells hold values. One sheet is current period
(9/30/2007) and the other sheet is prior period (6/30/2007). We are doing
an update sooooo...the data on the Current sheet (9/30/2007) will be moved
to the Prior sheet and new data (12/31/2007) will be pasted on the Current
sheet.

If I group the 2 sheets together, then manually go into each cell on the
Current sheet, edit the cell ([F2]) and then hit enter w/o making any
changes, the data on both sheets will be the same.

But, if I group the 2 sheets together, select the data range on the Current
sheet, then run the following code, it does not make the data on the Prior
sheet match the data on the Current sheet (Prior's data is unchanged...still
6/30/2007's data and not changed to 9/30/2007's data):

Sub LoopCells()
Dim c As Range
For Each c In Selection
c.Value = "zzz" & c.Value
c.Value = Replace(c.Value, "zzz", "")
Next c
End Sub

Why not? What is a quick, easy way to accomplish this?

Thanks for any help anyone can provide,

Conan Kelly


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Programmatically changing values on grouped sheets

try this. I selected 4 cells in col A of sheet1 and then held the ctrl key
and also selected sheet3 and then fired this using msgbox c. Seemed to work.

Sub doSelectedCellsforSelectedSheets()
'select cells in column
'ctrl and select sheets
'fire this
r1 = Selection.Cells(1, 1).Row
r2 = Rows(Selection.Row + Selection.Rows.Count - 1).Row
ac = Selection.Column
'MsgBox r1
'MsgBox r2
For Each sh In ActiveWindow.SelectedSheets
sh.Select
For Each c In ActiveSheet.Range(Cells(r1, ac), Cells(r2, ac))
'MsgBox c
c.Value = "zzz" & c.Value
c.Value = Replace(c.Value, "zzz", "")

Next c
Next sh
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Conan Kelly" wrote in message
...
Hello all,

I have 2 sheets that are identical in format, layout, formulas. The only
difference is some cells hold values. One sheet is current period
(9/30/2007) and the other sheet is prior period (6/30/2007). We are doing
an update sooooo...the data on the Current sheet (9/30/2007) will be moved
to the Prior sheet and new data (12/31/2007) will be pasted on the Current
sheet.

If I group the 2 sheets together, then manually go into each cell on the
Current sheet, edit the cell ([F2]) and then hit enter w/o making any
changes, the data on both sheets will be the same.

But, if I group the 2 sheets together, select the data range on the
Current sheet, then run the following code, it does not make the data on
the Prior sheet match the data on the Current sheet (Prior's data is
unchanged...still 6/30/2007's data and not changed to 9/30/2007's data):

Sub LoopCells()
Dim c As Range
For Each c In Selection
c.Value = "zzz" & c.Value
c.Value = Replace(c.Value, "zzz", "")
Next c
End Sub

Why not? What is a quick, easy way to accomplish this?

Thanks for any help anyone can provide,

Conan Kelly


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
Replace with Grouped Sheets Jim May Excel Discussion (Misc queries) 4 September 15th 06 02:19 PM
Changing footer programmatically in multiple sheets all at once alan674 Excel Programming 2 July 6th 05 11:28 AM
Grouped Sheets and Formating Pank Mehta Excel Discussion (Misc queries) 3 March 24th 05 01:42 AM
Changing Text in grouped shapes sebastienm Excel Programming 1 August 1st 04 02:54 PM
Printing Grouped Sheets Elaine Roden Excel Programming 4 May 31st 04 06:06 PM


All times are GMT +1. The time now is 06:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"