Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 363
Default Code to get Max Value in a perticular cell in ALL Sheets

I add sheets to a workbook sometimes on a daily basis and therefore do not know the last sheet
number or name until it has been created.

I need to gain the MAX value in cell J59 in ALL sheets, without having to NAME or KNOW the LAST
sheet, so if this changes i still get the correct MAX value.

Is there a line of code i can use for this ?

Corey....


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 363
Default Code to get Max Value in a perticular cell in ALL Sheets

Think i have a code that will work with a SLIGHT modification:
See arrow below in code:

Sub Workbook_Info()
On Error Resume Next
With Sheets("1") <==== How can i change THIS to ALL SHEETS in workbook INSTEAD
..Select
ActiveSheet.Unprotect
Range("R59").Select
ActiveCell.FormulaR1C1 = "=MAX('Enter-Exit Page:" & Worksheets(Worksheets.Count).Name &
"'!R[0]C[-8])"
End With
ActiveSheet.protect DrawingObjects:=True, Contents:=True, Scenarios:=True,
AllowFormattingCells:=True
End Sub



Corey....


"Corey" wrote in message ...
I add sheets to a workbook sometimes on a daily basis and therefore do not know the last sheet
number or name until it has been created.

I need to gain the MAX value in cell J59 in ALL sheets, without having to NAME or KNOW the LAST
sheet, so if this changes i still get the correct MAX value.

Is there a line of code i can use for this ?

Corey....



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Code to get Max Value in a perticular cell in ALL Sheets

If you run this code, the variable MaxValue will contain the maximum value
from all the R59 cells across all the worksheets (as shown by the MsgBox
statement at the end of the code)...

Sub MaxAcrossSheets()
Dim X As Long
Dim MaxValue As Double
Dim SheetName As String
MaxValue = Worksheets(1).Range("R29").Value
SheetName = Worksheets(1).Name
For X = 2 To Worksheets.Count
If Worksheets(X).Range("R29").Value MaxValue Then
MaxValue = Worksheets(X).Range("R29").Value
SheetName = Worksheets(X).Name
End If
Next
MsgBox "Maximum Value: " & MaxValue & vbNewLine & _
"Sheet Name: " & SheetName
End Sub

Rick


"Corey" wrote in message
...
Think i have a code that will work with a SLIGHT modification:
See arrow below in code:

Sub Workbook_Info()
On Error Resume Next
With Sheets("1") <==== How can i change THIS to ALL SHEETS in workbook
INSTEAD
.Select
ActiveSheet.Unprotect
Range("R59").Select
ActiveCell.FormulaR1C1 = "=MAX('Enter-Exit Page:" &
Worksheets(Worksheets.Count).Name &
"'!R[0]C[-8])"
End With
ActiveSheet.protect DrawingObjects:=True, Contents:=True,
Scenarios:=True,
AllowFormattingCells:=True
End Sub



Corey....


"Corey" wrote in message
...
I add sheets to a workbook sometimes on a daily basis and therefore do not
know the last sheet
number or name until it has been created.

I need to gain the MAX value in cell J59 in ALL sheets, without having to
NAME or KNOW the LAST
sheet, so if this changes i still get the correct MAX value.

Is there a line of code i can use for this ?

Corey....




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Code to get Max Value in a perticular cell in ALL Sheets

On Jan 21, 8:40*am, "Corey" wrote:
I add sheets to a workbook sometimes on a daily basis and therefore do not know the last sheet
number or name until it has been created.

I need to gain the MAX value in cell J59 in ALL sheets, without having to NAME or KNOW the LAST
sheet, so if this changes i still get the correct MAX value.

Is there a line of code i can use for this ?

Corey....



Dim Max as variant
Dim n As Single
For n = 1 To Sheets.Count
If n=1 then
Max = Worksheets(n).Range("J59")
Elseif Max < Worksheets(n).Range("J59")
Max = Worksheets(n).Range("J59")
Endif
Next n


HTH
Joe
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
any way to check if a cell with perticular text is in the same pla Narnimar Excel Discussion (Misc queries) 1 November 25th 08 10:27 PM
how do you match data and paste result in a perticular cell? KTN Excel Worksheet Functions 3 November 6th 08 07:33 PM
How do i set up blink a perticular cell? aziz Excel Discussion (Misc queries) 1 June 16th 08 03:33 PM
how to allow other users to make changes for some perticular cells make changes in work book Setting up and Configuration of Excel 2 October 19th 07 05:50 PM
Running macro on the perticular worksheet only vanessa h[_3_] Excel Programming 3 January 25th 06 10:41 AM


All times are GMT +1. The time now is 01:20 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"