A twist on auto increment of cell requested
Here is another approach you can consider...
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim Position As Long
On Error GoTo BadValue
With Worksheets("Sheet1").Range("G3")
Position = InStr(.Value, StrReverse(Val(StrReverse(.Value))))
.Value = Left(.Value, Position - 1) & Mid(.Value, Position) + 1
End With
Exit Sub
BadValue:
MsgBox "Bad Entry"
Cancel = True
End Sub
--
Rick (MVP - Excel)
"Andre Laurence" wrote in message
...
Hello,
I am sorry to ressurect an old issue, but I was wondering if someone could
tell me if the following is possible?
I have used :
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
With Worksheets("Sheet1").Range("G3")
.Value = .Value + 1
End With
End Sub
With great success and would like to thank everyone in this thread, but I
would like to know if there is a way to do this if the cell value is not
only a number (ie instead of just 12080250, IS12080250). The above code is
great, but issues a Runtime error 13 if there are any letters in the cell
value.
Thank you in advance.
|