'Add new row, increment last digit in alphanumerial string from cell below
New in VBA, did tried different examples available on the web but can't make it work as my string only increment by 1 & subsequent executions, the string stay the same.
Requirement: Adding a line above row 47. New cell A47 to increment last digit on alphanumerical string available in cell A48
My current code:
Dim Ws As Worksheet
Dim Updt As String
Dim num As Integer
Dim DD As String
Dim TT As String
num = num + 1
Updt = "Update/Mise À Jour #" 'ALPHANUMERIC STRING TO INCREMENT
DD = Date
TT = Time
Set Ws = ThisWorkbook.Worksheets("CF")
With Ws
.Rows(47).Copy
.Rows(47).Insert Shift:=xlShiftDown
.Range("A47:E47").ClearContents
.Range("B47") = DD & " " & TT
.Cells(47, 1).Value = Updt & num
End With
Any help will be apreciated.
Solution 1:[1]
After many trials, within my With, was able to make it work with this:
num = Right(Range"A48"), 2) .Range("A47") = "Update/Mise À Jour # " & Format(Int(num) + 1, "00")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Larry |