Deleting a range of cells.

  • Thread starter Always Learning
  • Start date
A

Always Learning

Hi Guys,

I have a VBA Macro that works on a sheet and I want to delete from B5 - B17
the problem is that cell A16 is a merged cell (A16 B16 C16)
When I use Range("B5:B17).Select it does not select just the cells in column
B it selects A5 - C5 down to A17- C17.
How can I get it to select only cells B5:B17. If I do it with the mouse
directly on the sheet it allows me to do it and ignores the merged cells.

Your help is appreciated.

Best Regards,

Steve Wilson.
 
A

Always Learning

Hi Guys,

Sorry, not true,
If I do it with the mouse directly on the sheet it does not allow me to do
it.
If I Mouse Click on Cell B5 and drag to B17 as soon as I pass over the
merged cells at B16 it selects columns A & C also.
Can I get around this?

Thanks,

Steve Wilson.



l...
 
J

Jean-Yves

HI Steve,

The problem is the the way you learned from the macro recorder code. The
extensive use of "Select"is NOT necessary.
Use range( "B5:B17).Clear

In general the code :
asdfsd.select
Selection.do_something
can be replaced by :
asdfasd.do_something


Regards

JY
 
A

Always Learning

Hi There,

This is a good idea but does not give me what I want. It leaves an empty,
odd looking column.

I have got around this by selecting the merged cells and removing the merge
element. Then I do the range selection and delete.

Works well and gives me what I wanted.

Thanks for your help & time.

Best Regards,


Steve Wilson.
 

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