I have an issue while using a variable containing a range.
I've declared the variable "rng" globally in the workbook module:
Public rng As Range
Now in a worksheet module I set the variable after clicking on a checkbox and define a range for it:
Sub CheckBox1_Click()
Set rng = Range("D8:Q51")
If Me.OLEObjects("checkbox1").Object.Value Then
Call clear(rng)
Else
Call aus(rng)
End If
End Sub
I always get an error when calling the sub "aus(rng)" which says:
error 438, object doesn't support this property or method
"aus(rng)" contains the following code:
Worksheets(5).rng.Copy Worksheets("aktuell").rng
Btw: using the range-variable in the same worksheet the module is connected to doesn't throw out an error. So the error somehow has to correlate with "Worksheets(5)".
rngin a normal module, not a workbook or worksheet module. - Garethrngis defined, isn't it grabbing the default book and sheet? So basically it is like writingSet rng = ActiveWorkbook.ActiveSheet.Range("D8:Q51")... - Chrismas007rng, theCall aus(rng)attempts to redefine it as belonging toWorksheets(5). It seems to be used closer to arng.Addressthan arng. There is also no need to even pass it across as a parameter if it is declared globally. - user4039065rngalready contains whichWorksheetit belongs to.Sheets(5).rngis incorrect. - John Alexiou