Requirement:
Sub newserial() Range("b10").Value = Range("b10").Value + 1 End Sub
This is a small code to generate new invoice number and the user wants a restriction value code with it.
If the value goes to 10 by pressing this button than it should show msg cannot go more than 10 value.
https://www.ozgrid.com/forum/forum/help-forums/excel-vba-macros/1202760-auto-generate-invoice-number
Solution:
Option Explicit Sub Macro2() If Range("B10") + 1 > 10 Then MsgBox "Ten (10) is the highest number available.", vbExclamation Exit Sub Else Range("B10").Value = Range("B10").Value + 1 End If End Sub
Obtained from the OzGrid Help Forum.
Solution provided by Trebor76.
See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets
See also:
How to use VBA code to print number of copies based on cell value |
How to use Excel VBA return values with same unique ID numbers |
How to paste a number as text |
How to create a macro for saving copy as csv with incremental file number |
Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.