Thread: assign variable
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 408
Default assign variable

Not sure what you mean Bob. i need two variables one which is greater than
the other by +1. The first variable needs to come from the number part of
LL-CP-0163 which is assigned to a cell and the other would be 164. similar is
i use LL-CP-0190 the second variable would be 191. Sorry i am not the best
with code.

"Bob Phillips" wrote:

If there are 2 - as per the example, use InstrRev

--

HTH

RP

"Norman Jones" wrote in message
...
Hi Tim.

One way:

Sub Atester()
Dim sStr As String
Dim pos As Long
Dim i As Long

sStr = "CP - 163"
pos = InStr(sStr, "-")
i = Mid(sStr, pos + 1) + 1
MsgBox i
End Sub

---
Regards,
Norman



"Tim" wrote in message
...
If a cell in a sheet is "LL-CP-0163" how can i set a variable in a macro
equal to 0163 or the number part of that cell. also how can i set

another
variable equal to 0164 or the previous variable + 1