WernerLouw
Board Regular
- Joined
- Dec 9, 2004
- Messages
- 93
I have this interrresting phenomenon...
Wrote the following code to clear comments from a list of sheets.
Sub ClearComments()
ThisWorkbook.Activate
Sheet1.Select
Range("g7:m42").ClearContents
Sheet2.Select
Range("g7:l33").ClearContents
Sheet3.Select
Range("g7:m31").ClearContents
'etc etc
End Sub
but it would not run past sheet 2, an error occured that said that merged cells need to b eidenitically sized. But the cells on all the sheets are merged. Then i changed the code in the following manner...
Sub ClearComments()
ThisWorkbook.Activate
Sheet1.Select
Range("g7:m42").ClearContents
Sheet2.Select
Range("g7:l33").Select
Selection.ClearContents
Sheet3.Select
Range("g7:m31").ClearContents
'etc etc
End Sub
Now it works without a glitch. What changed? all I am doing is I am selecting the range before clearing the contents...
Wrote the following code to clear comments from a list of sheets.
Sub ClearComments()
ThisWorkbook.Activate
Sheet1.Select
Range("g7:m42").ClearContents
Sheet2.Select
Range("g7:l33").ClearContents
Sheet3.Select
Range("g7:m31").ClearContents
'etc etc
End Sub
but it would not run past sheet 2, an error occured that said that merged cells need to b eidenitically sized. But the cells on all the sheets are merged. Then i changed the code in the following manner...
Sub ClearComments()
ThisWorkbook.Activate
Sheet1.Select
Range("g7:m42").ClearContents
Sheet2.Select
Range("g7:l33").Select
Selection.ClearContents
Sheet3.Select
Range("g7:m31").ClearContents
'etc etc
End Sub
Now it works without a glitch. What changed? all I am doing is I am selecting the range before clearing the contents...