Selecting Rows for Copying

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
 
B

Bernie Deitrick

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
 
B

Bad at VBA

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
 
B

Bad at VBA

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top