I have a simple spreadsheet comprising columns A to F. I want to copy just column D using VBA and copy to another column (as part of a larger macro). Simple so far. However. a number of the rows have the columns merged across all 6 so when I select the column using VBA all the columns are selected and copied. I just need to copy column D. My code is:
SelectedColumn="D" 'this is a user defined input variable
Columns(SelectedColumn).Select ' this is where it selects all columns A to F
Selection.Copy
i also tried with FirstRow and LastRow as variables corresponding to the first and last row to be copied but it still didn't work.
SelectedColumn="D" 'this is a user defined input variable
Columns(SelectedColumn & FirstRow,SelectedColumn & LastRow ).Select ' this is where it selects all columns A to F
Selection.Copy
but if I use Record Macro and click on column D at the top, I get
Columns("D:D").Select
Selection.Copy
and this ignores the rows with the merged columns.
Any suggestions? It would not be practicable to unmerge or delete the rows with the merged columns.
Thanks in advance.
Bookmarks