Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Giving run time error 13 on line pos = InStr(sStr, "-")
anyone know the problem with the code Sub Macro6() ' ' Macro6 Macro ' Macro recorded 10/1/2004 by Husky User ' Dim sStr As String Dim pos As Long Dim i As Long Dim j As Long Windows("LL-CP-0163.xls").Activate Range("J2").Select //J2 = LL-CP-0163 sStr = "J2" // Set sTtr to LL-CP-0163 pos = InStr(sStr, "-") // find - before 0163 i = Mid(sStr, pos + 1) + 1 // set i = 0163 + 1=164 j = i - 1 // j=163 MsgBox i MsgBox j Range("F" & i).Select End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Same as previous post
"Tim" wrote: Giving run time error 13 on line pos = InStr(sStr, "-") anyone know the problem with the code Sub Macro6() ' ' Macro6 Macro ' Macro recorded 10/1/2004 by Husky User ' Dim sStr As String Dim pos As Long Dim i As Long Dim j As Long Windows("LL-CP-0163.xls").Activate Range("J2").Select //J2 = LL-CP-0163 sStr = "J2" // Set sTtr to LL-CP-0163 pos = InStr(sStr, "-") // find - before 0163 i = Mid(sStr, pos + 1) + 1 // set i = 0163 + 1=164 j = i - 1 // j=163 MsgBox i MsgBox j Range("F" & i).Select End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry dave i wasn't impatient i accidently posted the question twice.
Thanks for your help "Don Guillett" wrote: You were telling excel to make your sstr "J2", not the contents of range("j2"). But, you need not select. ms=range("j2") pos=instr(ms,"-" i=mid(ms, etc Range("J2").Select //J2 = LL-CP-0163 sStr = "J2" // Set sTtr to LL-CP-0163 pos = InStr(sStr, "-") // find - before 0163 i = Mid(sStr, pos + 1) + 1 // set i = 0163 + 1=164 j = i - 1 // j=163 -- Don Guillett SalesAid Software "Tim" wrote in message ... Giving run time error 13 on line pos = InStr(sStr, "-") anyone know the problem with the code Sub Macro6() ' ' Macro6 Macro ' Macro recorded 10/1/2004 by Husky User ' Dim sStr As String Dim pos As Long Dim i As Long Dim j As Long Windows("LL-CP-0163.xls").Activate Range("J2").Select //J2 = LL-CP-0163 sStr = "J2" // Set sTtr to LL-CP-0163 pos = InStr(sStr, "-") // find - before 0163 i = Mid(sStr, pos + 1) + 1 // set i = 0163 + 1=164 j = i - 1 // j=163 MsgBox i MsgBox j Range("F" & i).Select End Sub |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Still getting the error with line
i = Mid(ms, pos + 1) + 1 "Don Guillett" wrote: You were telling excel to make your sstr "J2", not the contents of range("j2"). But, you need not select. ms=range("j2") pos=instr(ms,"-" i=mid(ms, etc Range("J2").Select //J2 = LL-CP-0163 sStr = "J2" // Set sTtr to LL-CP-0163 pos = InStr(sStr, "-") // find - before 0163 i = Mid(sStr, pos + 1) + 1 // set i = 0163 + 1=164 j = i - 1 // j=163 -- Don Guillett SalesAid Software "Tim" wrote in message ... Giving run time error 13 on line pos = InStr(sStr, "-") anyone know the problem with the code Sub Macro6() ' ' Macro6 Macro ' Macro recorded 10/1/2004 by Husky User ' Dim sStr As String Dim pos As Long Dim i As Long Dim j As Long Windows("LL-CP-0163.xls").Activate Range("J2").Select //J2 = LL-CP-0163 sStr = "J2" // Set sTtr to LL-CP-0163 pos = InStr(sStr, "-") // find - before 0163 i = Mid(sStr, pos + 1) + 1 // set i = 0163 + 1=164 j = i - 1 // j=163 MsgBox i MsgBox j Range("F" & i).Select End Sub |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() try Sub instrr() ms = Range("j2") pos = InStr(ms, "-") i = Mid(ms, pos + 1, 1) 'gets C MsgBox i End Sub -- Don Guillett SalesAid Software "Tim" wrote in message ... Still getting the error with line i = Mid(ms, pos + 1) + 1 "Don Guillett" wrote: You were telling excel to make your sstr "J2", not the contents of range("j2"). But, you need not select. ms=range("j2") pos=instr(ms,"-" i=mid(ms, etc Range("J2").Select //J2 = LL-CP-0163 sStr = "J2" // Set sTtr to LL-CP-0163 pos = InStr(sStr, "-") // find - before 0163 i = Mid(sStr, pos + 1) + 1 // set i = 0163 + 1=164 j = i - 1 // j=163 -- Don Guillett SalesAid Software "Tim" wrote in message ... Giving run time error 13 on line pos = InStr(sStr, "-") anyone know the problem with the code Sub Macro6() ' ' Macro6 Macro ' Macro recorded 10/1/2004 by Husky User ' Dim sStr As String Dim pos As Long Dim i As Long Dim j As Long Windows("LL-CP-0163.xls").Activate Range("J2").Select //J2 = LL-CP-0163 sStr = "J2" // Set sTtr to LL-CP-0163 pos = InStr(sStr, "-") // find - before 0163 i = Mid(sStr, pos + 1) + 1 // set i = 0163 + 1=164 j = i - 1 // j=163 MsgBox i MsgBox j Range("F" & i).Select End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Visual Basic Error Run Time Error, Type Mismatch | Excel Discussion (Misc queries) | |||
Run time error 1004, General ODBC error | New Users to Excel | |||
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error | Excel Programming | |||
Code Error - Run Time Error 5 (Disable Cut, Copy & Paste) | Excel Programming | |||
Run-time error '11' & Run-time error '1004' | Excel Programming |