Running a macro in a selected cell...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This is probably a simple question, but I can't seem to figure it out...

I want to run a task of pasting several rows and columns of information into
a cell that is selected by the user.

I recorded a Macro and asigned it to a rectangular button that will copy the
information, but how can I make it paste the information starting in the
selected cell?

Thanks in advance.
 
dim RngToCopy as range

Set rngtocopy = worksheets("sheet99").range("a1:b99") 'or something

rngtocopy.copy _
destination:=activecell

=========
You could even ask where it should be pasted:

dim RngToCopy as range
Dim DestCell as range

set destcell = nothing
on error resume next
set destcell = application.inputbox(prompt:="select a cell",type:=8).cells(1)
on error goto 0

if destcell is nothing then
exit sub 'user hit cancel
end if

Set rngtocopy = worksheets("sheet99").range("a1:b99") 'or something

rngtocopy.copy _
destination:=destcell
 
Thank you Dave.

Dave Peterson said:
dim RngToCopy as range

Set rngtocopy = worksheets("sheet99").range("a1:b99") 'or something

rngtocopy.copy _
destination:=activecell

=========
You could even ask where it should be pasted:

dim RngToCopy as range
Dim DestCell as range

set destcell = nothing
on error resume next
set destcell = application.inputbox(prompt:="select a cell",type:=8).cells(1)
on error goto 0

if destcell is nothing then
exit sub 'user hit cancel
end if

Set rngtocopy = worksheets("sheet99").range("a1:b99") 'or something

rngtocopy.copy _
destination:=destcell
 
Back
Top