ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   I need help with a macro (https://www.excelbanter.com/excel-programming/290216-i-need-help-macro.html)

Rusty[_4_]

I need help with a macro
 
I need to write a macro to copy data from one cell, then prompt me for
what cell to paste it in. Please help!

Tom Ogilvy

I need help with a macro
 
Dim rng as Range
On Error Resume Next
set rng = Application.InputBox("Select Destination with mouse", type:=8)
On Error goto 0
if not rng is nothing then
selection.Copy Destination:=rng(1)
Else
msgbox "You hit cancel"
End if

--
Regards,
Tom Ogilvy

"Rusty" wrote in message
om...
I need to write a macro to copy data from one cell, then prompt me for
what cell to paste it in. Please help!




Kevin Beckham

I need help with a macro
 
Use the Application.InputBox function to return a cell
reference, checking to make sure the Cancel key wasn't
selected, viz.

Sub PasteMyValue()
Dim pasteCell As Range
Dim targetCell As Range

Set pasteCell = ActiveCell
On Error Resume Next
Set targetCell = Application.InputBox("Select cell to
paste contents", _
"My Paste Function", ActiveCell.Offset(1,
0).Address, , , , , 8)
If Not (targetCell Is Nothing) Then
'next 2 lines to paste special
pasteCell.Copy
targetCell.PasteSpecial xlPasteValues
'or this to paste the cell
'pasteCell.copy targetCell
End If
End Sub

Kevin Beckham
-----Original Message-----
I need to write a macro to copy data from one cell, then

prompt me for
what cell to paste it in. Please help!
.



All times are GMT +1. The time now is 02:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com