Hi everyone!
I have a sub that I want to use on various checkboxes on various sheets. So I set the checkbox as a variable called Cbx:
Here's what I've got:
And when I call in another sub such as:
I get an error message for the line "Call Checkbox". In the version above the message being "Type mismatched". I've also tried putting in the variable as Checkboxes("Check Box 2") (Here message "sub or function not defined"), or Checkbox(Check Box 2) or Check box 2 (Here message "ByRef Argument type mismatched)... In the first Sub I've also tried writing "Cbx As Checkbox" and "Cbx As Checkboxes"
Does anyone know how to refer to the Checkbox so that it works??
Thanks in advance!
(P.S: Also in the first Sub
work but if I put in the next line
I get an error message "PasteSpecial Method of Worksheet Class Failed"
If someone knows the answer to this other problem I would be grateful as well!)
I have a sub that I want to use on various checkboxes on various sheets. So I set the checkbox as a variable called Cbx:
Here's what I've got:
VBA Code:
Sub Checkbox(Copysheet As Worksheet, ButtonSheet As Worksheet, Cbx As Checkbox)
Application.ScreenUpdating = False
If Workbooks("BCTF").ButtonSheet.Cbx.Value = 1 Then
Copysheet.Select
Range("A2:E" & Range("A" & Rows.Count).End(xlUp).Row).Select
Selection.Copy
With Sheets("tdq")
.Select
.Range("C" & Rows.Count).End(xlUp).Offset(1).Select
.Paste
.PasteSpecial xlPasteColumnWidths
End With
Workbooks("BCTF").ButtonSheet.Activate
Else
Reset
End If
Application.ScreenUpdating = True
End Sub
And when I call in another sub such as:
VBA Code:
Sub CheckBox11Off()
Call Checkbox(Sheets("Off"), Sheets("MCO"), Checkbox("Check Box 2"))
End Sub
I get an error message for the line "Call Checkbox". In the version above the message being "Type mismatched". I've also tried putting in the variable as Checkboxes("Check Box 2") (Here message "sub or function not defined"), or Checkbox(Check Box 2) or Check box 2 (Here message "ByRef Argument type mismatched)... In the first Sub I've also tried writing "Cbx As Checkbox" and "Cbx As Checkboxes"
Does anyone know how to refer to the Checkbox so that it works??
Thanks in advance!
(P.S: Also in the first Sub
VBA Code:
.Paste
.PasteSpecial xlPasteColumnWidths
VBA Code:
. PasteSpecial xlPasteFormats
If someone knows the answer to this other problem I would be grateful as well!)