AshwinKumar
New Member
- Joined
- Jan 9, 2013
- Messages
- 3
Within the Excel 2007 Visual Basic Editor, when I declare a variable as a Worksheet object and then, within a subroutine, set that variable to point to a worksheet object, if I start typing the code 'ws.', Excel crashes.
Normally upon typing the . after ws, I would expect the Visual Basic Editor's autocomplete function to bring up from the object model a drop down list of all of the members (methods, properties, etc.) of the worksheet object for me to choose from. However this does not happen and Excel crashes instead.
Other uses of the Visual Basic Editor's autocomplete function (e.g. where a variable is declared as and assigned to a range) do not prompt a crash - I've only noticed it with variables assigned to worksheet objects. The problem has been happening for the last few weeks.
My workaround is to use alternative text in place of ws (e.g. 'x.Cells(1,1).Clear') and then later use a find and replace to put ws back into my code at the relevant points but whenever I forget to do this whilst I'm in the middle of typing code, Excel crashes and I have to restart and go back to back to my last save - very frustrating!
I'm running Excel 2007 (12.0.6665.5003) SP3 MSO (12.0.6662.5000).
Has anyone else experienced this problem and can anyone offer a solution.
Many thanks for any help at all.
Normally upon typing the . after ws, I would expect the Visual Basic Editor's autocomplete function to bring up from the object model a drop down list of all of the members (methods, properties, etc.) of the worksheet object for me to choose from. However this does not happen and Excel crashes instead.
Other uses of the Visual Basic Editor's autocomplete function (e.g. where a variable is declared as and assigned to a range) do not prompt a crash - I've only noticed it with variables assigned to worksheet objects. The problem has been happening for the last few weeks.
My workaround is to use alternative text in place of ws (e.g. 'x.Cells(1,1).Clear') and then later use a find and replace to put ws back into my code at the relevant points but whenever I forget to do this whilst I'm in the middle of typing code, Excel crashes and I have to restart and go back to back to my last save - very frustrating!
I'm running Excel 2007 (12.0.6665.5003) SP3 MSO (12.0.6662.5000).
Has anyone else experienced this problem and can anyone offer a solution.
Many thanks for any help at all.
Code:
Dim ws As Worksheet
Dim rng As Range
Sub ExampleSub()
Set ws = ActiveSheet
Set rng = ws.Range(ws.Cells(1, 1), ws.Cells(1, 1))
MsgBox rng.Rows.Count
ws.
End Sub