ActiveCell.Row noncontiguous

G

Guest

I am using the ActiveCell.Row to copy and paste cell content.

Range("K" & ActiveCell.Row & ":" & "M" & ActiveCell.Row).Copy

It allows the user to perform certain functions without being concerned
about which columns to select.
Many times they will be selecting multiple rows. Is there a modification to
this routine that allows for the
selection of multiple or noncontiguous rows?

Thanks,
Steve
 
G

Guest

Steve,

Maybe something like this:

Sub test()

Dim c As Range
Dim rngCopy As Range

If TypeName(Selection) = "Range" Then
For Each c In Selection
If rngCopy Is Nothing Then
Set rngCopy = Range("K" & c.Row & ":" & "M" & c.Row)
Else
Set rngCopy = Application.Union(rngCopy, Range("K" & c.Row & ":"
& "M" & c.Row))
End If
Next c
rngCopy.Copy
End If


End Sub
 
B

Bob Phillips

Multiple is easy

Range("K" & ActiveCell.Row & ":" & "M" & ActiveCell.Row).Resize(10).Copy

non-contiguous isn't.


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
G

Guest

Vergel,

I am at the tail end of a project and have posted a couple of questions,
this being one of them.
I have searched the web and read books trying to resolve this puzzle. Your
code works exactly as I had hoped for.
I know it's relative, but to me, this is genius.

Cheers mate!
 

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