Greetings,
Below is the line giving me trouble. I am receiving the error "method range of object worksheet failed".
This line exists within the below script:
Below is the line giving me trouble. I am receiving the error "method range of object worksheet failed".
Code:
I = ws.Range(Cells(2, "A")).Row
This line exists within the below script:
Code:
Sub TRENDSHEET()
Dim ws As Worksheet
Dim PA As Workbook
Dim TA As Workbook
Dim A As Integer
Dim B As Integer
Dim D As Integer
Dim E As Integer
Dim F As Integer
Dim G As Integer
Dim H As Integer
Dim I As Integer
Dim J As Integer
Dim K As Integer
Dim L As Integer
Dim M As Integer
Dim N As Integer
Dim AA As Range
Dim BB As Range
Dim CC As Range
Dim DD As Range
Dim R1 As Range
Dim R2 As Range
Set TA = Workbooks("COMM_TREND.xls")
Set PA = Workbooks("COMM_PA.xls")
For Each ws In PA.Worksheets
A = ws.Cells(Rows.Count, "A").End(xlUp).Row
Do Until A = 2
If ws.Cells(A, "E").Value > Application.Large(ws.Cells((A - 10), "E").Resize(21), 2) Then
Set AA = ws.Cells(A, "E")
Set DD = ws.Cells(A, "A")
G = AA.Row
H = ws.Cells(A, "A").Row
TA.ws.Activate
Range("A1").Select
Selection.End(xlDown).Offset(1, 0).Select
Selection.Value = "ACTIVE"
Range("A1").Select
Selection.End(xlDown).Offset(0, 1).Select
Selection.Value = DD.Value
Range("A1").End(xlDown).Offset(0, 2).Select
Selection.Value = AA.Value
A = E
Do Until E - 10 = 2
I = ws.Range(Cells(2, "A")).Row
Set CC = PA.ws.Range(Cells(G, "A"), Cells(I, "A")
D = E - 10
Set R1 = PA.ws.Range(Cells(G, "A")).Row
For Each R1 In CC
H = PA.ws.Range(Cells(E, "A")).Row
BB = PA.ws.Range(Cells(G, "A"), Cells(I, "A"))
Set R2 = PA.ws.Range(Cells(G, "A")).Row
For Each R2 In BB
B = PA.ws.Range(Cells(D, "E").Value - PA.ws.Range(Cells(G, "E")).Value) / PA.ws.Range(Cells(D, "A").Value - PA.ws.Range(Cells(G, "A")).Value)
C = PA.ws.Range(Cells(D, "A"), Cells(G, "A")).Rows.Count
I = PA.ws.Range(Cells(D, "E").Value - PA.ws.Range(Cells(G, "E")).Value)
F = A - (A - H)
J = PA.ws.Range(Cells(H, "A").Value - Cells(G, "A").Value).Rows.Count
If PA.ws.Range.Cells(H, "E").Value > AA.Value + (B * F) And F < C + 10 Then
ElseIf PA.ws.Range.Cells(H, "E").Value > AA.Value + (B * F) And F > C + 10 Then
TA.ws.Range("A1").End(xlDown).Offset(1, 0).Select
Selection.Value = "ACTIVE"
PA.ws.Range.Cells(H, "A").Value.Copy
TA.ws.Range("A1").End(xlDown).Offset(0, 1).Select
Selection.Paste PasteSpecial:=xlValues
AA.Value.Copy
TA.ws.Range("A1").End(xlDown).Offset(0, 2).Select
Selection.Paste PasteSpecial:=xlValues
PA.ws.Range.Cells(D, "A").Value.Copy
TA.ws.Range("A1").End(xlDown).Offset(0, 3).Select
Selection.Paste PasteSpecial:=xlValues
PA.ws.Range.Cells(D, "E").Value.Copy
TA.ws.Range("A1").End(xlDown).Offset(0, 4).Select
Selection.Paste PasteSpecial:=xlValues
TA.ws.Range("A1").End(xlDown).Offset(0, 5).Value = C
TA.ws.Range("A1").End(xlDown).Offset(0, 6).Value = I
TA.ws.Range("A1").End(xlDown).Offset(0, 7).Value = B
TA.ws.Range("A1").End(xlDown).Offset(0, 8).Select
Selection.Paste PasteSpecial:=xlValues
PA.ws.Range.Cells(H, "A").Value.Copy
TA.ws.Range("A1").End(xlDown).Offset(0, 9).Select
Selection.Paste PasteSpecial:=xlValues
ElseIf PA.ws.Range.Cells(H, "E").Value < AA.Value + (B * F) Then
End If
Next R2
Next R1
E = E - 1
Loop
Else
A = A - 1
End If
Loop
Next ws
End Sub