Question about unmerged columns

npanag

New Member
Joined
Jan 7, 2011
Messages
45
I have F12 and G12 as merged cells in an xls file that is exported from Navision. Clicking on F12 and pressing CTRL-Space to select the whole merged area (F:G), it selects a bigger area (A:J) because of some merged cells above F12.
But if I click on the column letters F and G, I can select only these two columns.

I recognize that F12 is a merged cell with Activecell.MergeArea.Columns.Count that gives 2,
and I have the address from Activecell.MergeArea.address ($F$12:$G$12)

How can I imitate in VBA the clicking of F and G and select only these two columns and not A:J?

I used range(Activecell.MergeArea.address).EntireColumn.Select, but it selects again A:J

Thank you
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
maybe
columns(F:G).select

if you can get rid of merged cells and use the visual "centre across selection" that would be easier to work with
 
Upvote 0
Hi,
columns(F:G).select selects whole A:J area.
The file is produced by Navision. For now, I treat it "as is".
So, I open the file programmatically, I search the Title area if there are merged cells and if yes, I unmerge them.
But I haven't found a way of selecting in code only the columns that are merged. In my example I find that F12 is a merged cell consisted of F12 and G12, so I want to select in code only the merged cells columns F and G.
Instead of this, because of other merged cells, it selects A:J area, therefore I unmerge this whole area. But with the mouse, if I click on F and G, I am able to select only these 2 columns. Is there something in VBA code to imitate this? I mean to bypass the merged cells that exist above F12 and select only F and G column?




 
Upvote 0
Best option is not to select them, but use something like this instead
Code:
With Range("F:G")
   .Interior.Color = 45678
End With
 
Upvote 0
ok, new sheet manual AJ merge, then recorded your intended actions and got

Code:
Range("F:F,G:G").Select
 
Upvote 0
Just to help you reproduce the problem:
Go to a new worksheet - Merge cells a1:c1 - Go to cell B5, or C4, or A8 whatever and press CTRL-Space. You will that the whole area A:C is selected.
But if you click on B of column name B, then it selects only B column.
Or, if you go to the Immediate window and write "Activecell.entirecolumn.select" with one cell of A, B, or C column selected, then it selects all three columns.
I wonder if I am in a cell of these 3 columns, write something in VBA code, that does this click only the one column.
The same, if you are in B4 and you write
Columns("B").select
It will select again the three columns.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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