Increase count by 1 but ignore multiple characters to the left

Watchdawg

Board Regular
Joined
Jan 21, 2015
Messages
53
I've seen a few things around for something similar, but I'm starting to wonder if this is possible...

I formula that finds the last filled cell in range "A". That cell contains the following text "DEV-19-1". I need to increment the last digit (will eventually be 2 digits), but ignore the first 7 characters. I was seeing a lot about using the left/mid/right commands but I don't think that will do what I need it to. Here's the current formula:

HTML:
TextBox1.Value = Sheets("Log").Range("A:A").End(xlDown).Value + 1
Any thoughts or am I going about this all wrong?
*quick update, I will need to retain those first 7 characters in the userform, so the form would return DEV-19-2
 
Last edited:

njimack

Well-known Member
Joined
Jun 17, 2005
Messages
7,761
Something like this...

Code:
Sub x()
Dim str As String
Dim Increment As Long
With Sheets("Log").Cells(Rows.Count, 1).End(xlDown)
    str = Left(.Value, 7)
    Increment = Replace(.Value, str, "") + 1
End With
TextBox1.Value = str & Increment
    
End Sub
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
31,991
Office Version
365
Platform
Windows
How about
Code:
   Dim St As String
   St = Sheets("Log").Range("A" & Rows.Count).End(xlUp).Value
   Me.TextBox1.Value = Left(St, InStrRev(St, "-")) & Right(St, Len(St) - InStrRev(St, "-")) + 1
 

Watchdawg

Board Regular
Joined
Jan 21, 2015
Messages
53
PERFECT! Both answers worked well! Thank you both so much! That was driving me batty
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
31,991
Office Version
365
Platform
Windows
You're welcome & thanks for the feedback
 

Forum statistics

Threads
1,081,543
Messages
5,359,431
Members
400,526
Latest member
Brook1083

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top