copy paste issue with macro

jessie4558

New Member
Joined
Jun 28, 2012
Messages
4
Kindly help me on this. this macro is working i just need somebody to modify it to allow copying of values only. some of the source cells are formula.
here is the macro that i use.


Sub extractrr()

' "I7" will be copied to "A9"
' "k7" will be copied to "F9"
' "n7" will be copied to "g9"
Dim response As Long, Lastrow As Long
Dim src As Worksheet, Dst As Worksheet
Dim c As Range, flag As Boolean
flag = False
Dim MyRange As Range, K As Long
K = 9
Set src = Sheets("in")
Set Dst = Sheets("RR")
response = Application.InputBox("Enter Key number", "Search", Type:=1)
Dst.Range("B9:B19").EntireRow.ClearContents
Lastrow = src.Cells(Cells.Rows.Count, "E").End(xlUp).Row
Set MyRange = src.Range("E7:E" & Lastrow)
For Each c In MyRange
If c.Value = response Then
c.Offset(, 4).Copy Dst.Range("B" & K)
Dst.Range("B" & K).HorizontalAlignment = xlLeft
c.Offset(, 6).Copy Dst.Range("G" & K)
Dst.Range("G" & K).HorizontalAlignment = xlLeft
c.Offset(, 9).Copy Dst.Range("H" & K)
Dst.Range("H" & K).HorizontalAlignment = xlLeft

K = K + 1
flag = True
End If
If K = 20 Then Exit Sub
Next
If flag = False Then
MsgBox "No matches found for key number " & response
End If

End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Can you try the format...

Code:
c.Offset(,4).Copy
Dst.Range("B" & K).PasteSpecial Paste:=xlPasteValues

... instead? :/
 
Last edited:
Upvote 0
Thanks for the feedback and you're very much welcome!

In case of doubt about any action, always try Record Macro first. That's what I did. I just recorded the right-click-press-"V" method and it showed that part. I truncated the useless part and left xlPasteValues instead. :)
 
Upvote 0

Forum statistics

Threads
1,207,423
Messages
6,078,441
Members
446,338
Latest member
AliB

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top