Auto increment cell value when macro is run

Jnb99

Board Regular
Joined
Mar 29, 2016
Messages
84
Hi everyone,

I have a workbook used for invoices and estimates.

Each time I save a estimate i.e click button on template sheet, a new sheet must be created with cell value as sheet name. My code is as follow, which works perfectly:
VBA Code:
Sub Rectangle1_Click()

    Dim ws As Worksheet

    Set wh = Worksheets(ActiveSheet.Name)
    ActiveSheet.Copy After:=Worksheets(Sheets.Count)
    If wh.Range("e3").Value <> "" Then
    ActiveSheet.Name = wh.Range("e3").Value
    End If
    wh.Activate
With Sheets("Estimate").Range("e3")
    .Value = .Value + 1
End With
End Sub

My problem comes in when I add an "E" before the cell value in E3 (which is the estimate number).
I assume split function will need to be used? I have no experience with it.

Thank you in advance.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
If you have an "E" in front of the value in cell E3, maybe try changing this part:
VBA Code:
    .Value = .Value + 1
to this:
VBA Code:
    .Value = "E" & (Mid(.Value, 2) + 1)
 
Upvote 0
Solution
You are welcome!
Glad I was able to help.
 
Upvote 0

Forum statistics

Threads
1,214,987
Messages
6,122,613
Members
449,090
Latest member
vivek chauhan

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