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
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