Consulting

Results 1 to 3 of 3

Thread: paste cell offset to right???

  1. #1

    paste cell offset to right???

    I'm trying to copy a figure weekly via macro and paste it starting from B2 then to next avaliable space to the right (this will be 52 weeks so will be B2-BA2 in total)
    The code I have works perfectly for counting down, but changed it and it only pastes the one time?

    Where am I going wrong???


    [VBA]Worksheets("End of week summary").Range("E4").Copy
    Worksheets("Sheet1").Range("B2" & Columns.Count).End(xlUp).Offset(0, 1).PasteSpecial xlPasteValues[/VBA]

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    hi.
    try:

    [VBA]
    Worksheets("Sheet1").Range("B" & Columns.Count).End(xlToLeft).Offset(0, 1).PasteSpecial xlPasteValues [/VBA]
    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)

  3. #3
    VBAX Mentor Teeroy's Avatar
    Joined
    Apr 2012
    Location
    Sydney, Australia
    Posts
    414
    Location
    With pastespecial I've found it necessary to activate the destination sheet, even when its location is fully referenced. If you are only copying one cell value (derived from formula) and using pastespecial then it may be simpler to simply assign it. e.g.

    [VBA]Worksheets("Sheet1").Range("B" & Columns.Count).End(xlToLeft).Offset(0, 1) = Worksheets("End of week summary").Range("E4")[/VBA]
    _________________________________________________________________________
    "In theory there is no difference between theory and practice. In practice there is." - Chuck Reid

    Any day you learn something new is a day not wasted.

Posting Permissions

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