Advertisement
YasserKhalil2019

T3783_Increment Using Static

Aug 23rd, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. https://excel-egy.com/forum/t3783
  2. ---------------------------------
  3.  
  4. Sub Increment_Using_Static()
  5. Static x As Long
  6. Dim v As Variant
  7.  
  8. x = x + 1
  9.  
  10. If x = 1 Then
  11. Range("A1").Value = "asd-001"
  12. Else
  13. v = Range("A1").Value
  14. Range("A1").Value = Split(v, "-")(0) & "-" & Format(Val(Split(v, "-")(1)) + 1, "000")
  15. End If
  16. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement