Thread: assign variable
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default assign variable

Hi Bob,

Yes, mia culpa, the consequence of not using the OP's sanple data.!

Thank you.

---
Regards,
Norman



"Bob Phillips" wrote in message
...
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