macro to find a max value in a column select corresponding userfor

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to create a macro that will find the max value in a column and use
that value to select a userform.
The worksheet with the data is called "Raw Data". In column A, the data
could look like 1,2,3,4,5,6,7,8,9,10,11,12. I want to find the max value
(12) and have the macro select UserForm12. The max value (in this case 12)
will also be used to select the appropriate worksheet for UserForm12 which
will be "Logsheet12".
This will OPEN the appropriate userform and loghseet. The other worksheets
will be hidden from the user. Excuse the redundancy
 
Try something like this. I used the worksheet function max and then used a
case select based on the max value.


Sub maxvalue()

Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set maxrange = Range(Cells(1, "A"), Cells(Lastrow, "A"))

maximumvalue = WorksheetFunction.Max(maxrange)

Select Case maximumvalue

Case 12
Worksheets("Logsheet12").Activate

End Select

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top