Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
r r is offline
external usenet poster
 
Posts: 125
Default finding largest value

Using VBA I need to find the largest number in column A over all my sheets.
So say I have 5 sheets in my workbook I want to find the largest number
within all the column A's. Then just set what ever this number is to a
variable I have in my code (say intI)--this part is simple. I am new to
programming within the Excel environment so I'm not sure how to do the first
part.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default finding largest value

R,

Try something like this:

Sub test()
Dim sht As Worksheet
Dim lValue As Long
Dim lLargest As Long

For Each sht In ActiveWorkbook.Worksheets
lValue = Application.WorksheetFunction.Large(sht.Range("A:A "), 1)
If lValue lLargest Then lLargest = lValue
Next sht

MsgBox lLargest

End Sub


--
Hope that helps.

Vergel Adriano


"R" wrote:

Using VBA I need to find the largest number in column A over all my sheets.
So say I have 5 sheets in my workbook I want to find the largest number
within all the column A's. Then just set what ever this number is to a
variable I have in my code (say intI)--this part is simple. I am new to
programming within the Excel environment so I'm not sure how to do the first
part.

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
r r is offline
external usenet poster
 
Posts: 125
Default finding largest value

Awesome....thanks so much

"Vergel Adriano" wrote:

R,

Try something like this:

Sub test()
Dim sht As Worksheet
Dim lValue As Long
Dim lLargest As Long

For Each sht In ActiveWorkbook.Worksheets
lValue = Application.WorksheetFunction.Large(sht.Range("A:A "), 1)
If lValue lLargest Then lLargest = lValue
Next sht

MsgBox lLargest

End Sub


--
Hope that helps.

Vergel Adriano


"R" wrote:

Using VBA I need to find the largest number in column A over all my sheets.
So say I have 5 sheets in my workbook I want to find the largest number
within all the column A's. Then just set what ever this number is to a
variable I have in my code (say intI)--this part is simple. I am new to
programming within the Excel environment so I'm not sure how to do the first
part.

Thanks

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
Finding the largest match XJSquared Excel Worksheet Functions 9 July 19th 09 05:45 PM
Help with finding largest value paula Excel Worksheet Functions 2 February 6th 05 10:51 PM
Finding and Showing the Largest arjcvg Excel Worksheet Functions 1 October 29th 04 05:11 AM
Finding and Showing the Largest arjcvg Excel Worksheet Functions 2 October 29th 04 03:01 AM
Finding the largest value Kamal[_4_] Excel Programming 11 February 13th 04 12:30 PM


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