LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 915
Default Find the lowest number in a given column

Colin Hayes wrote:
In article , smartin
writes
Colin Hayes wrote:

Hi

I need a small macro to find the lowest number in a given column , and
then replace it with a number input through a popup.


Can anyone help?


Grateful for any assistance.


Try this:

Sub ReplaceIt()
Dim TheMin As Variant
Dim TheOffset As Long
Dim TheCell As String
Dim TheNewValue As Variant

TheMin = Application.WorksheetFunction. _
Min(Range("A:A"))
TheOffset = Application.WorksheetFunction. _
Match(TheMin, Range("A1:A9999"), 0)
TheCell = Range("A1").Offset(TheOffset - 1).Address

TheNewValue = InputBox("Minimum value found was " & _
TheMin & ". Enter value to replace.")
Range(TheCell).Value = TheNewValue
End Sub


Hi

OK thanks very much for helping.

It works fine , but only changes one value , rather than all the
matching ones.

For example , it found the lowest to be 1.95 and I asked it to change
this to 1.25. It did it , but only to the first occurrence of a cell
with 1.95 and left all the others intact. Could it be tweaked to change
all cells with the lowest value?

Also , because the column I need it to work on could vary would it be
possible to enter the column to be selected via a popup and for it to
work on the whole column down to the last row wherever that is?

Grateful again for you advice.



Best Wishes


Hi Colin, sorry for the late reply.
Without creating a user form, the approach I would take would be:

- Sub1 with input box to query user for the column, call and pass result
to Sub2.

- Sub2 with input box to query user for min value, then leverage
Application.WorksheetFunction.Replace and the column reference obtained
above to do the heavy lifting.

Sorry I don't feel like coding just now, post back if you get stuck!
 
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 the number of the lowest filled row Roberto Villa Real Excel Worksheet Functions 3 May 2nd 08 03:26 PM
find lowest number and return it's adjacent cell Erik Excel Worksheet Functions 7 October 2nd 07 02:37 PM
How to find the lowest number of a row and delete it automatically awinslow Excel Discussion (Misc queries) 1 October 10th 06 01:20 AM
find the lowest value in a row and add a number to it Kim Excel Worksheet Functions 4 September 28th 05 05:27 PM
how do i find the lowest number in a column in Excel? MKA808 Excel Discussion (Misc queries) 4 August 23rd 05 07:27 PM


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