Hello,
Need help in the below code. I am calling a command button sub procedure using the loop. When I did it without loop I used Sheet3.CommandButton3_Click and it worked fine. But, then I am doing it using loop then I change it to ActiveSheet.CommandButton3_Click which is throwing error. wsa is the worksheet object and I don't know how to call the command button procedure using activesheet or anyother way?
Need help in the below code. I am calling a command button sub procedure using the loop. When I did it without loop I used Sheet3.CommandButton3_Click and it worked fine. But, then I am doing it using loop then I change it to ActiveSheet.CommandButton3_Click which is throwing error. wsa is the worksheet object and I don't know how to call the command button procedure using activesheet or anyother way?
Rich (BB code):
cd = 1
ci = 10
For Each wsa In ThisWorkbook.Worksheets
If Left(wsa.Name, 2) = Format(cd, "00") Then
in1 = "Sheet" & wsa.Index
wsa.Activate
ActiveSheet.Range("R2").Value = "'" & Sheet4.Range("E8").Value
ActiveSheet.Range("R3").Value = Sheet4.Range("B" & ci).Value
'Call Sheet3.CommandButton3_Click
Call ActiveSheet.CommandButton3_Click
cd = cd + 1
ci = ci + 1
End If
Next wsa