ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run time error 13 (https://www.excelbanter.com/excel-programming/312192-run-time-error-13-a.html)

Tim

Run time error 13
 
Giving me run time error 13 when try to compile from line
pos = InStr(sStr, "-") below


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 equals
LL-CP-0163
sStr = "J2" //sStr equal
LL-CP 0163
pos = InStr(sStr, "-") // finds "-" before
0163
i = Mid(sStr, pos + 1) + 1 // sets i as 0163 +1= 164
j = i - 1 // sets j as 163
MsgBox i // shows values
MsgBox j //shows values
Range("F" & i).Select
End Sub

Don Guillett[_4_]

Run time error 13
 
see later answer and show a bit of patience. We are all volunteers here.

--
Don Guillett
SalesAid Software

"Tim" wrote in message
...
Giving me run time error 13 when try to compile from line
pos = InStr(sStr, "-") below


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 equals
LL-CP-0163
sStr = "J2" //sStr equal
LL-CP 0163
pos = InStr(sStr, "-") // finds "-"

before
0163
i = Mid(sStr, pos + 1) + 1 // sets i as 0163 +1=

164
j = i - 1 // sets j as

163
MsgBox i // shows values
MsgBox j //shows values
Range("F" & i).Select
End Sub





All times are GMT +1. The time now is 06:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com