Consulting

Results 1 to 3 of 3

Thread: Cut and past a selected row to another worksheet

  1. #1

    Cut and paste a selected row to another worksheet

    Hi,
    I’m completely new to any sort of VBA.
    Please keep that in mind if I’m asking some stupid questions
    What I want to achieve is probably not that difficult for someone who knows what their doing, I hope so at least.

    I would like to make a macro that automatically cuts a selected row from the “Geplande afspraken” sheet and paste it to the “Afspraak geschiedenis” sheet. The data should always be pasted in the first available emty row. If possible I would like to do this by pressing a "button" on the sheet itself, not via a keyboard shortcut.
    Cry_for_help.xlsm

    Could some kindhearted person help me with that?
    Would be much appreciated!


    Kind regards
    (and sorry if my English is not that great)
    Last edited by dajodj; 09-12-2018 at 07:08 AM.

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

    copy below code to a standard module (or Geplande afspraken's code module) and assign it to the button Klantenlijst in sheet Geplande afspraken (cell F3)

    Sub vbax_63629_cut_paste()
    
        Dim rww As Long, lbr As Long
        
        With Worksheets("Afspraak geschiedenis")
            lbr = .Columns("B").Find("*", .Cells(1, 2), xlValues, xlPart, xlByRows, xlPrevious).Offset(1).Row
        End With
        
        rww = ActiveCell.Row
        
        With Range("B" & rww & ":F" & rww)
            .Copy
            Worksheets("Afspraak geschiedenis").Range("B" & lbr).PasteSpecial xlPasteValues 'in order to keep destination cells' formats
            .ClearContents 'in order to keep source cells' formats
        End With
    
    End Sub
    if you want to run it without using a button, do it after selecting the sheet Geplande afspraken.
    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
    Got it working like a charm.
    Thanks a lot! I appreciate the help!

Posting Permissions

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