NerakSeven
New Member
- Joined
- Jan 6, 2019
- Messages
- 14
I create a button in sheet1 and this is works only in this sheet not in sheet46. The problem is I need this button in another page(sheet46) I mean call this action from another sheet46 with the same reference (check sheet 1 and sheet2)
Why don’t works?
Code:
Private Sub CommandButton1_Click()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim lr1 As Long
Dim lr2 As Long
Set ws1 = Sheet(“Sheet1”)
Set ws2 = Sheet(“Sheet2”)
lr1 = ws1.Cells(Rows.Count, "A").End(xlUp).Row
lr2 = ws2.Cells(Rows.Count, "A").End(xlUp).Row
For x = 2 To lr2
If Cells(x, "B") <> Application.WorksheetFunction.SumIfs(ws1.Range("I2:I" & lr1), ws1.Range("A2:A" & lr1), Cells(x, "A")) Then
ws2.Cells(x, "I") = "Not correct"
End If
Next x
End Sub
I hope u can help me ,
Regards
Why don’t works?
Code:
Private Sub CommandButton1_Click()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim lr1 As Long
Dim lr2 As Long
Set ws1 = Sheet(“Sheet1”)
Set ws2 = Sheet(“Sheet2”)
lr1 = ws1.Cells(Rows.Count, "A").End(xlUp).Row
lr2 = ws2.Cells(Rows.Count, "A").End(xlUp).Row
For x = 2 To lr2
If Cells(x, "B") <> Application.WorksheetFunction.SumIfs(ws1.Range("I2:I" & lr1), ws1.Range("A2:A" & lr1), Cells(x, "A")) Then
ws2.Cells(x, "I") = "Not correct"
End If
Next x
End Sub
I hope u can help me ,
Regards