PDA

View Full Version : VBA msgbox help



Unkownzuck
05-01-2018, 06:27 AM
Hello,

I need some help to figure out this msgbox. I have found the minimum value in a range, and want to show the given information for that specific data.
So I want to show data from the lowest number, but can't seem to figure it out.

I have attached a screenshot of the problem.

cheers,

SamT
05-01-2018, 08:14 AM
Sorry, unkownzuck, We are not going to switch back and forth from Excel to the internet browser just to type all that into Excel.

But, if you select and copy the Code in the VBA Editor, then in our post editor, click the # icon and press Ctrl+V it will put your code into your post.

Also, it helps if you post all the code, from "Sub" to "End Sub"



To get you started...
Always, always, always, declare Row and Column Counters as Long.

Now that you have found the Min...

'After the Min code
RowNumber = rng.Find(dblMin).Row
'Then the MsgBox code

That will show the data for only the first min Row in the Range. With over 18,000 values, there are sure to be several that are tied for the lowest.

Another thing, it is best practice to only work on the smallest range possible. To avoid dealing with a Range with lots of empty cells at the bottom...

Set rng = Range(Range("E5"), Cells(Rows.count, "E").End(xlUp))

If you just want the Row number of the bottom non-empy cell in column A...


Rw = Cells(Rows.Count, "A").End(xlUp).Row

Paul_Hossler
05-01-2018, 10:10 AM
I need some help to figure out this msgbox. I have found the minimum value in a range, and want to show the given information for that specific data.
So I want to show data from the lowest number, but can't seem to figure it out.

I have attached a screenshot of the problem.


What SamT said.

1. The screen shot is a piece of the macro, which while it probably is the problem, it does not show any issues or results

2. Just reading my crystal ball, it sort of looks like you never assign a value to rownumber, so it's = 0 which causes Cells (rownumber, ...) to fail

3. Since 'can't figure it out' doesn't say what issues (error messages, bad results, etc.) you're having, that's just a guess