Thingol
Technical User
- Jan 2, 2002
- 169
Hi there,
I'm struggling with a problem. I have some code that runs when the window of a workbook deactivates (Workbook_WindowDeactivate). The problem is that I want to use a range in a sheet of the workbook of which the window is being deactivated. The code should test the values of the cells in the range, and depending on the values perform some further actions. The problem that occurs, is that as soon as I want to select a range of cells(1) or I just want to refer to a range(2), error messages pop up:
(1)
ThisWorkbook.Worksheets("Blad1".Range("AA2".Select
'I get an error message that the selection of the object
'class range didn't work.
(2)
dim Range1 as Range
Range1 = ThisWorkbook.Worksheets("Blad1".Range("AA2"
'Error 91:
'Objectvariable or blockvariable with is not set.
Why can't I refer to these cells using the .Range property of cells in the workbook that is being deactivated? it should work from within the WindowDeactivate event, shouldn't it? What's going wrong?
I'm struggling with a problem. I have some code that runs when the window of a workbook deactivates (Workbook_WindowDeactivate). The problem is that I want to use a range in a sheet of the workbook of which the window is being deactivated. The code should test the values of the cells in the range, and depending on the values perform some further actions. The problem that occurs, is that as soon as I want to select a range of cells(1) or I just want to refer to a range(2), error messages pop up:
(1)
ThisWorkbook.Worksheets("Blad1".Range("AA2".Select
'I get an error message that the selection of the object
'class range didn't work.
(2)
dim Range1 as Range
Range1 = ThisWorkbook.Worksheets("Blad1".Range("AA2"
'Error 91:
'Objectvariable or blockvariable with is not set.
Why can't I refer to these cells using the .Range property of cells in the workbook that is being deactivated? it should work from within the WindowDeactivate event, shouldn't it? What's going wrong?