Consulting

Results 1 to 8 of 8

Thread: Elegant Way to Copy Cells from one Sheet to Another - Value only

  1. #1

    Elegant Way to Copy Cells from one Sheet to Another - Value only

    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.

  2. #2
    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
    Last edited by jolivanes; 06-16-2016 at 09:55 AM. Reason: more possibilities

  3. #3
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    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
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  4. #4
    @ mancubus.
    Yes, indeed. Works for a single cell. I don't know why I was thinking multiple cells.

  5. #5
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    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.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  6. #6
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    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
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  7. #7
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
       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))

  8. #8
    You all are awesome. Thank you for the help! Works like a champ. I'll ad CODE TAGS next time. My bad on that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •