Which Excel are you targeting? 97 and 2002 will accept the same code, IF you are EXTREMELY CAREFUL about coding.
Merged cells are the bugaboo; I suggest the following:
If you use "Set" statements to create Range variables to refer to merged cells, the variable should reference the top left cell, only.
Don't expect to .ClearContents, instead use ".Value = vbNullString"
Any of the _Change events that have the argument "Target as Range" will return a vartype() of array in 97, in 2002, the Vartype will be the variable contained. To deal with potential type mismatches, it is best to use the Target(1,1) construct. That will keep 97 and 2002 happy.
If you do use Range variables, just keep in mind that any run-time error that halts the code will set the Range variable to Nothing. I compensate by having all the "Set n = Cells(row,col)" Range variable assignments in their own routine, and calling it in my error handling routines, just in case.
For the Real Gurus out there, please suggest improvements/corrections to anything said here. I will appreciate.
_________________ This message was edited by stevebausch on 2002-10-24 21:57
I have a macro that selects a cell using
For Each cl In Rg
If cl = "" And cl.MergeArea.Columns.Count = 1 And Not cl.EntireColumn.Hidden And Not cl.EntireRow.Hidden And cl.Column <= C - cn And cl.Row <= r - rn Then
I need to know the cell number of the cell selected.