I need help with a macro

  • Thread starter Thread starter Rusty
  • Start date Start date
R

Rusty

I need to write a macro to copy data from one cell, then prompt me for
what cell to paste it in. Please help!
 
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
 
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
 
Back
Top