Home |
Search |
Today's Posts |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Norman heres what i have but it is not coded correct, here is what i
am trying to do thinking i = # and j = # -1 and what is "MsgBox i". ' Macro recorded 9/30/2004 by Husky User ' Sub Atester() Dim sStr As String Dim pos As Long Dim i As Long Dim j As Long Windows"current sheet".Activate Range("J2").Select sStr = "J2" pos = InStrRev(sStr, "-") i = Mid(sStr, pos + 1) + 1 j = i - 1 MsgBox i MsgBox j Windows("LL-CP-j.xls").Activate Range("F3:H3").Select Application.CutCopyMode = False Selection.Copy Windows("Completions LL Register 2004-09-030.xls").Activate Range("F"i"").Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False End Sub "Norman Jones" wrote: Hi Tim, As Bob indicates, I mis-read your data. Given that the required numeric string follows the second hyphen character in your data, the InsrRev function should be used. The suggested macro thus becomes: Sub Atester() Dim sStr As String Dim pos As Long Dim i As Long sStr = "CP - 163" pos = InStrRev(sStr, "-") i = Mid(sStr, pos + 1) + 1 MsgBox i End Sub --- Regards, Norman "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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Assign value to a variable name | Excel Discussion (Misc queries) | |||
Assign value to variable | Excel Discussion (Misc queries) | |||
Variable VB to assign new sheet name | Excel Worksheet Functions | |||
Sum Cells and assign to variable | Excel Programming | |||
VBA routine to assign first name only to a variable | Excel Programming |