PDA

View Full Version : Elegant Way to Copy Cells from one Sheet to Another - Value only



whatsapro
06-16-2016, 08:40 AM
I found a way to copy with formatting and formulas; however, I just want the value.

wkb.Sheets("F100 Supportability").Range("A" & Target.Row).Copy Destination:=ws.Range("A1") 'Nomen
cwkb.Sheets("F100 Supportability").Range("O" & Target.Row).Copy Destination:=ws.Range("A2") 'PDN
cwkb.Sheets("F100 Supportability").Range("P" & Target.Row).Copy Destination:=ws.Range("A2") 'CNDM
cwkb.Sheets("F100 Supportability").Range("E" & Target.Row).Copy Destination:=ws.Range("D5") 'A
cwkb.Sheets("F100 Supportability").Range("F" & Target.Row).Copy Destination:=ws.Range("E5") 'F
cwkb.Sheets("F100 Supportability").Range("H" & Target.Row).Copy Destination:=ws.Range("B5") 'QDR

Does anyone know how I can copy just the value and paste it?

Thanks.

jolivanes
06-16-2016, 09:44 AM
Don't know if it is elegant enough but this works for me.
Obviously, change references as required.

ActiveSheet.Range("B2:B4").Copy
Range("E4").PasteSpecial xlPasteValues


Or, if it needs to be an elegant one liner, try this

wkb.Sheets("F100 Supportability").Range("A" & Target.Row).Value.Copy: ws.Range("A1").PasteSpecial xlPasteValues
You might want to consider using

Application.CutCopyMode = False
at the end to clear the stored data

mancubus
06-16-2016, 10:40 AM
pls use code tags



ws.Range("A1").Value = cwkb.Sheets("F100 Supportability").Range("A" & Target.Row).Value
ws.Range("A2").Value = cwkb.Sheets("F100 Supportability").Range("O" & Target.Row).Value
ws.Range("A2").Value = cwkb.Sheets("F100 Supportability").Range("P" & Target.Row).Value
ws.Range("D5").Value = cwkb.Sheets("F100 Supportability").Range("E" & Target.Row).Value
ws.Range("E5").Value = cwkb.Sheets("F100 Supportability").Range("F" & Target.Row).Value
ws.Range("B5").Value = cwkb.Sheets("F100 Supportability").Range("H" & Target.Row).Value

jolivanes
06-16-2016, 11:32 AM
@ mancubus.
Yes, indeed. Works for a single cell. I don't know why I was thinking multiple cells.

mdmackillop
06-16-2016, 12:02 PM
ws.Range("A2").Value = cwkb.Sheets("F100 Supportability").Range("O" & Target.Row).Value
ws.Range("A2").Value = cwkb.Sheets("F100 Supportability").Range("P" & Target.Row).Value

Surely not.

SamT
06-16-2016, 08:31 PM
With cwkb.Sheets("F100 Supportability").Rows(Target.Row)
ws.Range("A1") = .Cells(1)
ws.Range("A2") = .cells(14) '<--- A2
ws.Range("A2") = .Cells(15) '<--- A2
ws.Range("D5") = .Cells(5)
ws.Range("E5") = .Cells(6)
ws.Range("B5") = .Cells(8)
End With

snb
06-17-2016, 01:48 AM
sn = Sheets("F100 Supportability").Rows(Target.Row)
ws.Range("A2:B2") = Array(sn(1, 15), sn(1, 16))
ws.Range("B5:E5") = Array(sn(1, 8), , , sn(1, 6), sn(1, 5))

whatsapro
06-17-2016, 10:21 AM
You all are awesome. Thank you for the help! Works like a champ. I'll ad CODE TAGS next time. My bad on that.