Find Largest Value in column plus one.

mobman

New Member
Joined
Jun 18, 2011
Messages
12
This one is probably super easy for you guys...need to figure out how to set a variable to the largest value in a column plus one...example:

C1 = 5
C2 = 3
C3 = 4
C4 = 1

New value would be 6.


Dim NewValue as Long

NewValue = (insert formula here) + 1


Thank you for your help & time!
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Try:

NewValue = Application.Max(Range("C:C")) + 1
 
Upvote 0
Try:
Code:
Sub IncrementMax ()

Dim NewValue as Long

NewValue = Application.Max(Range("C1:C" & Range("C" & Rows.Count).End(xlUp).Row)) + 1
MsgBox NewValue

End Sub
 
Upvote 0
Thanks for taking the time...here is one more revision to the requirements:

there are two different data sets example:


Item No Dataset
1 A
120 B
5 A
9 A
119 B

The higher item numbers correspond to Dataset B and the lower item numbers to Dataset A.

How would I code this in vba to look at the two columns, figure out the two datasets then add the appropriate next number plus 1. For example (with the data above).

If new item added is in dataset A then next number is 10
If new item added is in dataset B then next number is 121.
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top