Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Subscript out of range
In the code below I get message "Subscript out of range"
I think it's to do with the asterisked line, not too sure. Sub desI() Worksheets.Add.Name = "Changes" k = 2 For i = 1 To 200 For j = 1 To 200 ** If Worksheets("J").Cells(i, j) < Worksheets("J2").Cells(i, j) Then Worksheets("J").Cells(i, j).EntireRow.Copy _ Destination:=Worksheets("Changes").Cells(k, 1) Worksheets("J2").Cells(i, j).EntireRow.Copy _ Destination:=Worksheets("Changes").Cells(k + 1, 1) With Worksheets("Changes") .Cells(k + 1, 1).ClearContents For m = 2 To 20 .Cells(k + 2, m).Value = .Cells(k, m) - .Cells(k + 1, m) With .Cells(k + 2, m).borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlMedium .ColorIndex = xlAutomatic End With Next m End With k = k + 4 Exit For End If Next j Next i End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Subscript out of range
Hi
is this the line which is highlighted. If yes, do both sheets named 'J' and 'J2' exist? -- Regards Frank Kabel Frankfurt, Germany teresa wrote: In the code below I get message "Subscript out of range" I think it's to do with the asterisked line, not too sure. Sub desI() Worksheets.Add.Name = "Changes" k = 2 For i = 1 To 200 For j = 1 To 200 ** If Worksheets("J").Cells(i, j) < Worksheets("J2").Cells(i, j) Then Worksheets("J").Cells(i, j).EntireRow.Copy _ Destination:=Worksheets("Changes").Cells(k, 1) Worksheets("J2").Cells(i, j).EntireRow.Copy _ Destination:=Worksheets("Changes").Cells(k + 1, 1) With Worksheets("Changes") .Cells(k + 1, 1).ClearContents For m = 2 To 20 .Cells(k + 2, m).Value = .Cells(k, m) - .Cells(k + 1, m) With .Cells(k + 2, m).borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlMedium .ColorIndex = xlAutomatic End With Next m End With k = k + 4 Exit For End If Next j Next i End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Subscript out of Range | Excel Discussion (Misc queries) | |||
what does 'Subscript Out of range' mean?? | Excel Worksheet Functions | |||
subscript out of range | Excel Programming | |||
Subscript out of range | Excel Programming | |||
SubScript Out Of Range. | Excel Programming |