macro to determine if cell is blank

T

Tonso

Using XL2002, I have created a spreadsheet that has numbers in column
A. The cells in column A are merged, so the first cell is A14:A15,
then A16:A17, etc.. Dependng on circumstances, the last cell in the
region is either A72:A73 or A140:A141. I have a macro that inserts a
new number anywhere in the current region of column A, When I insert
a new number in the column, i would want to delete the last number,
which will be, once i insert a new number, in A74:A75, or A142:A143.
What VBA code do i need to add to my procedure to tell Excel to delete
the rows 74:75 or rows 142:143?


Thanks,

Tonso
 
C

CLR

This might help.......

Application.Goto Reference:="R65000C1"
Selection.End(xlUp).Select
Selection.ClearContents
Selection.EntireRow.Delete

Vaya con Dios,
Chuck, CABGx3
 
P

Per Jessen

Chuck,
You can not use ".ClearContents" on merged cells


To OP use this to delete values in last (merged) cell in column A:

Range("A" & Rows.Count).End(xlUp) = ""

Regards,
Per
 
C

CLR

You must have run in to an Excel version variance. It works fine for me in
XL2k

Vaya con Dios,
Chuck, CABGx3
 
P

Per Jessen

Wierd,

Selection.ClearContents works on merged cells, but not if you use a range
reference like Range("A1").ClearContents it doesn't.

Regards,
Per
 
C

CLR

Interesting.......thanks for the "heads up".

I generally try to avoid merged cells as much as possible, but if one were
to run in to trouble, maybe they could be treated like "protection", by first
unmerging, then doing your business, then re-merging.......

Do you know if there is any way to determine with code what cells might be
merged to any specific cell?......so tey could be re-merged without having to
know the range in advance.

Vaya con Dios,
Chuck, CABGx3
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top