PDA

View Full Version : [SOLVED:] Cut and past a selected row to another worksheet



dajodj
09-12-2018, 06:27 AM
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.
22865

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


Kind regards
(and sorry if my English is not that great)

mancubus
09-12-2018, 11:38 PM
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.

dajodj
09-14-2018, 04:30 AM
Got it working like a charm.
Thanks a lot! I appreciate the help!