run time error 9 plz help :(

hatemhatem

New Member
Joined
Mar 1, 2010
Messages
21
hi, i have a problem in using vba and each time I run my project I get

Runtime error "9" Subscript out of range :'(

and the line of code in question is:

pr_pri.Worksheets("wspr_pri").Cells(13, 4).Activate

here's the entire code for the macro:

Code:
Sub prpri()
Dim i%, j%, k%
Dim iLRA As String, iLRN As String
Dim Y As Boolean, Ys As Boolean
Dim TabloA(), TabloN()
Dim pr As Workbook, pri As Workbook, pr_pri As Workbook
Dim wspr As Worksheet, wspri As Worksheet, wspr_pri As Worksheet
'Détermination du nombre de ligne de Classeur "pr" et "pri" et "pr_pri"
Set pr = Workbooks("PR_DETAIL(GD330_ANLDSV).xls")
Set pri = Workbooks("GD330AT-00-V10o-204-XX-JAN-12-2010+0_PRI.xls")
Set pr_pri = Workbooks("PR-PRI Check 2.2 GD330AT-00-V10o-204-XX-JAN-12-2010+0_PRI.xls")
Set wspr = pr.Worksheets("PR_DETAIL(GD330_ANLDSV)")
Set wspri = pri.Worksheets("PRI DATA")
Set wspr_pri = pr_pri.Worksheets("Feuil1")
Workbooks("PR_DETAIL(GD330_ANLDSV).xls").Activate
Workbooks("GD330AT-00-V10o-204-XX-JAN-12-2010+0_PRI.xls").Activate
Workbooks("PR-PRI Check 2.2 GD330AT-00-V10o-204-XX-JAN-12-2010+0_PRI.xls").Activate
pr_pri.Worksheets("wspr_pri").Cells(13, 4).Activate
pr.Worksheets("wspr").Range("D5").Activate
pri.Worksheets("wspri").Range("F9").Activate
iLRA = Worksheets("wspr").Range("D5").Value
Worksheets("wspr_pri").Range("D13").Value = iLRA
iLRN = Worksheets("wspri").Range("F9").Value
Worksheets("wspr_pri").Range("E13").Value = iLRN
If iLRA <> iLRN Then
Worksheets("wspr_pri").Range("H13").Value = "NG"
Else: Worksheets("wspr_pri").Range("H13").Value = "OK"
End If
End Sub



plz help
 
Last edited by a moderator:
it's done and the new code is :
Sub prpri()
Dim i%, j%, k%
Dim iLRA As String, iLRN As String
Dim Y As Boolean, Ys As Boolean
Dim TabloA(), TabloN()
Dim pr As Workbook, pri As Workbook, pr_pri As Workbook
Dim wspr As Worksheet, wspri As Worksheet, wspr_pri As Worksheet
'Détermination du nombre de ligne de Classeur "pr" et "pri" et "pr_pri"
Set pr = Workbooks("PR_DETAIL(GD330_ANLDSV).xls")
Set pri = Workbooks("GD330AT-00-V10o-204-XX-JAN-12-2010+0_PRI.xls")
Set pr_pri = Workbooks("PR-PRI Check 2.2 GD330AT-00-V10o-204-XX-JAN-12-2010+0_PRI.xls")
Set wspr = pr.Worksheets("PR_DETAIL(GD330_ANLDSV)")
Set wspri = pri.Worksheets("PRI DATA")
Set wspr_pri = pr_pri.Worksheets("Feuil1")
Workbooks("PR_DETAIL(GD330_ANLDSV).xls").Activate
Workbooks("GD330AT-00-V10o-204-XX-JAN-12-2010+0_PRI.xls").Activate
Workbooks("PR-PRI Check 2.2 GD330AT-00-V10o-204-XX-JAN-12-2010+0_PRI.xls").Activate
wspr_pri.Range("D13").Value = wspr.Range("D5")
wspr_pri.Range("E13").Value = wspri.Range("F9")
If wspr_pri.Range("D13").Value <> wspr_pri.Range("E13").Value Then
wspr_pri.Range("H13").Value = "NG"
Else: wspr_pri.Range("H13").Value = "OK"
End If
End Sub

thanx for you Mr VOG :)
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top