ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting a range of cells. (https://www.excelbanter.com/excel-programming/358067-deleting-range-cells.html)

Always Learning

Deleting a range of cells.
 
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.



Always Learning

Deleting a range of cells.
 
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...
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.





Jean-Yves[_2_]

Deleting a range of cells.
 
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


"Always Learning" <NoMoreSpam@MyEmail wrote in message
...
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.





Always Learning

Deleting a range of cells.
 
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.

"Jean-Yves" wrote in message
...
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


"Always Learning" <NoMoreSpam@MyEmail wrote in message
...
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.








All times are GMT +1. The time now is 04:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com