Problem selection column (merged cells)

Defumator

New Member
Joined
Mar 14, 2012
Messages
13
Good morning,
I have an excel sheet with data in 4 columns, i am want to create a macro that delete the first column, i m using this code:
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
there is some merged cell (A:D), so the macro select the 4 columns. I learned this code using ''record macro'', but when i select the entire column manually, it just select one column, but when i use the macro, it select all 4.
Is there a way to select just one column with these merged cells??
thank you very much:)
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Welcome to the Board!

I would highly recommend getting rid of the merged cells. They cause nothing but problems (as you can see!), and most serious programmers avoid them at all costs.

You can get the same visual effect by using "Center Across Selection" without all the issues that merged cells cause. Here is a link that talks about that, and how to do that: http://www.officearticles.com/excel/merged_cells_in_microsoft_excel.htm
 
Upvote 0
Thank you!
i don't like using merged cell either! the problem is that the sheet is a report imported from another program (Project Scheduler 7), so i can't change the layout of the report...
 
Upvote 0
As long as you are creating a macro, you can put a line at the very top that will first unmerge all your cells. You should then be able to do what you want after that without issues.

That line of code would look like:
Code:
    Cells.MergeCells = False
 
Upvote 0
Your welcome!

Actually, you can also get that code by using the Macro Recorder (highlight your whole sheet, select Format, and uncheck the Merge Cells box). I just cleaned it up a little (as the Macro Recorder often takes about 10 lines to do what can be written in 1 line).

Works fine either way though!
 
Upvote 0
I am having a similar problem but using the "unmerge" code makes the excel page unreadable. Do you have any other suggestions? Thank you!!
 
Upvote 0
I am having a similar problem but using the "unmerge" code makes the excel page unreadable. Do you have any other suggestions?
Did you then use "Center Across Selection" on each one to fix it up after unmerging, like was discussed above?
 
Upvote 0

Forum statistics

Threads
1,215,425
Messages
6,124,827
Members
449,190
Latest member
rscraig11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top