Selecting Rows for Copying

  • Thread starter Thread starter Bad at VBA
  • Start date Start date
B

Bad at VBA

Hi,

I've been happily using a macro that has been copying and pasting data
for me. However, I have recently encountered an issue where the sheets
I am copying my data from have merged cells.

As far as I can tell, Selection.Rows.Count will not work as desired
when some columns are merged, but others are not. Basically it is
counting what may be 100 rows of data as one row, due to the cell
merging.

' select all lines except title
Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select

Is there another way to select all of the data, excluding the header
row, when columns A is merged, but columns B has individual rows worth
of data?

Column A Column B
Header row Header row
Data data
data
data
data
Data data
data

Thanks
 
It is not a problem with Selection.Rows.Count, which works even with merged cells (at least in
XL2003, for me). The problem is what you do with the selection....

Still, you could try

Selection.Offset(1, 1).Resize(Selection.Rows.Count - 1).Select

HTH,
Bernie
MS Excel MVP
 
I will give that a try. Thank you!

It is not a problem with Selection.Rows.Count, which works even with merged cells (at least in
XL2003, for me).  The problem is what you do with the selection....

Still, you could try

Selection.Offset(1, 1).Resize(Selection.Rows.Count - 1).Select

HTH,
Bernie
MS Excel MVP
 
Hi Bernie,

You were correct, I was on the wrong track as far as where my issue
was originating. But your response helped me identify the issue and
get it resolved. So thank you very much.
 
Back
Top