![]() |
Running a macro in a selected cell...
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. |
Running a macro in a selected cell...
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 Steve wrote: 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. -- Dave Peterson |
Running a macro in a selected cell...
Thank you Dave.
"Dave Peterson" wrote: 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 Steve wrote: 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. -- Dave Peterson |
All times are GMT +1. The time now is 12:44 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com