Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 184
Default Visual Script to find smallest number greater than 0

I am looking for a script to find the smallest number greater than 0 in a
column and select it.

Thank you
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Visual Script to find smallest number greater than 0

Hi,

Here's a brute force way

Sub ChangelinkT()
Dim MyMin As Long, LastRow As Long
Dim MyRange As Range
LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRange = Range("A1:A" & LastRow)
MyMin = WorksheetFunction.Max(MyRange)
For Each c In MyRange
If c.Value 0 And c.Value < MyMin Then
TheMin = c.Address
MyMin = c.Value
End If
Next
Range(TheMin).Select
End Sub

Mike

"Jeremy" wrote:

I am looking for a script to find the smallest number greater than 0 in a
column and select it.

Thank you

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 184
Default Visual Script to find smallest number greater than 0

Does this go under a Sub Macro?

Thanks

"Mike H" wrote:

Hi,

Here's a brute force way

Sub ChangelinkT()
Dim MyMin As Long, LastRow As Long
Dim MyRange As Range
LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRange = Range("A1:A" & LastRow)
MyMin = WorksheetFunction.Max(MyRange)
For Each c In MyRange
If c.Value 0 And c.Value < MyMin Then
TheMin = c.Address
MyMin = c.Value
End If
Next
Range(TheMin).Select
End Sub

Mike

"Jeremy" wrote:

I am looking for a script to find the smallest number greater than 0 in a
column and select it.

Thank you

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Visual Script to find smallest number greater than 0

Hi,

You can right click your sheet tab, view code and put it in there.

or better

You can open VB editor, right click 'ThisWorkbook' and insert module and put
it there and it will work on the active sheet i.e. the sheet that is visible.

Mike

"Jeremy" wrote:

Does this go under a Sub Macro?

Thanks

"Mike H" wrote:

Hi,

Here's a brute force way

Sub ChangelinkT()
Dim MyMin As Long, LastRow As Long
Dim MyRange As Range
LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRange = Range("A1:A" & LastRow)
MyMin = WorksheetFunction.Max(MyRange)
For Each c In MyRange
If c.Value 0 And c.Value < MyMin Then
TheMin = c.Address
MyMin = c.Value
End If
Next
Range(TheMin).Select
End Sub

Mike

"Jeremy" wrote:

I am looking for a script to find the smallest number greater than 0 in a
column and select it.

Thank you

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
Find X number of smallest values in a range Steve Haack Excel Worksheet Functions 1 August 14th 07 05:02 AM
countif formula to find the occurances of a number that is greater than one number but less than another steveo Excel Discussion (Misc queries) 3 July 8th 06 02:04 AM
How can I get Excel to find the first number in a list greater tha krowlan Excel Worksheet Functions 3 October 27th 05 06:15 PM
find smallest number not equal to 0 dave Excel Worksheet Functions 2 April 20th 05 10:56 PM
The formula to find the smallest number in a row not equal to zero seastheday Excel Worksheet Functions 8 April 14th 05 11:58 PM


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