Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default WHy does it only work on Menu SHeet

The following Code is designed to scroll thru all the
sheets in a workbook and update them, the last part of the
code only works on the menu sheet it has no effect on the
other worksheets.

I have 2 questions

1. Rather than looking thru a range of cells on the menu
sheet for the sheet name is their a way I can just go thru
each worksheet in a book and process it AND

2. Why does the Code only work on the menu sheet when in
theory it is not the active sheet

Any questions please feel free to email me

Application.ScreenUpdating = True
Dim cell As Range, rng As Range
Dim sh As Worksheet
With Worksheets("Menu")
Set rng = .Range(.Cells(2, 14), .Cells(2, 14).End(xlDown))
End With
For Each cell In rng
Set sh = Worksheets(cell.Value)
Sheets(sh.Name).Activate
If Not Sheets("Menu").Range("G22") Is Nothing Then
Sheets(sh.Name).Range("B2").End(xlToRight).Offset( 0, 1) =
value1
Sheets(sh.Name).Range("B3").End(xlToRight).Offset( 0, 1) =
value2
Sheets(sh.Name).Range("B4").End(xlToRight).Offset( 0, 1) =
value3
End If

Application.Run Macro:=("EssMenuRetrieve")


Set LastCol = Cells(2, Columns.Count).End(xlToLeft)
Set rng = Range("b2", LastCol)

For Each oCell In rng

If oCell < "" Then
oCell.ColumnWidth = 13
Else
oCell.ColumnWidth = 1

End If
Next oCell

Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default WHy does it only work on Menu SHeet

qualify your range references with the sheets you want to refer to.

--
Regards,
Tom Ogilvy

"Nigel Bennett" wrote in message
...
The following Code is designed to scroll thru all the
sheets in a workbook and update them, the last part of the
code only works on the menu sheet it has no effect on the
other worksheets.

I have 2 questions

1. Rather than looking thru a range of cells on the menu
sheet for the sheet name is their a way I can just go thru
each worksheet in a book and process it AND

2. Why does the Code only work on the menu sheet when in
theory it is not the active sheet

Any questions please feel free to email me

Application.ScreenUpdating = True
Dim cell As Range, rng As Range
Dim sh As Worksheet
With Worksheets("Menu")
Set rng = .Range(.Cells(2, 14), .Cells(2, 14).End(xlDown))
End With
For Each cell In rng
Set sh = Worksheets(cell.Value)
Sheets(sh.Name).Activate
If Not Sheets("Menu").Range("G22") Is Nothing Then
Sheets(sh.Name).Range("B2").End(xlToRight).Offset( 0, 1) =
value1
Sheets(sh.Name).Range("B3").End(xlToRight).Offset( 0, 1) =
value2
Sheets(sh.Name).Range("B4").End(xlToRight).Offset( 0, 1) =
value3
End If

Application.Run Macro:=("EssMenuRetrieve")


Set LastCol = Cells(2, Columns.Count).End(xlToLeft)
Set rng = Range("b2", LastCol)

For Each oCell In rng

If oCell < "" Then
oCell.ColumnWidth = 13
Else
oCell.ColumnWidth = 1

End If
Next oCell

Next



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default WHy does it only work on Menu SHeet

Hi,
I'm not entirely sure what you are trying to achieve here so perhaps a
better explanation will result in a better response but this should get
you started...

This code will loop thru all worksheets not called Menu and perform the
same operation on each sheet. In your example you don't tell us
what/where value1, value2 etc come from...

Dim objWs As Worksheet, intInc As Integer

For Each objWs In ThisWorkbook.Worksheets
With objWs
If Not .Name = "Menu" Then
.Cells(2, 2).End(xlToRight)(1, 2).Value = Value1
.Cells(3, 2).End(xlToRight)(1, 2).Value = Value2
.Cells(4, 2).End(xlToRight)(1, 2).Value = Value3
Call EssMenuRetrieve
End If
End With
Next objWs


hth,
OJ

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 to make find menu on excel work sheet? johans Excel Worksheet Functions 0 November 26th 07 08:31 AM
extracting totals from 1 work sheet to another work work sheet cj Excel Discussion (Misc queries) 2 October 27th 07 10:54 PM
GETTING SELECTED DATA FROM A WORK SHEET TO OTHER WORK SHEET kumar Excel Discussion (Misc queries) 0 October 4th 06 01:34 PM
i am missing work sheet menu bar Diesel Excel Discussion (Misc queries) 1 May 26th 06 10:42 PM
Populating work sheet combox with another work sheet values sjayar Excel Discussion (Misc queries) 1 October 29th 05 03:22 PM


All times are GMT +1. The time now is 05:55 AM.

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"