Forum Discussion
adrian_hafredal
Aug 29, 2022Copper Contributor
macro move line from one sheet to another
Hi all, I have never made a macro befor and i need some help. I need a macro Which is triggered by putting a name in the drop-down menu in column "L". I have 3 names to be sorted into 3 d...
OliverScheurich
Aug 29, 2022Gold Contributor
Sub three_names()
Dim i As Long
Dim k As Long
Dim l As Long
l = Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To l
If Cells(i, 10).Value = "remove" Then
Select Case Cells(i, 1).Value
Case Is = "A"
k = Worksheets("nom de site " & Cells(i, 1).Value).Range("A" & Rows.Count).End(xlUp).Row
Range(Cells(i, 1), Cells(i, 9)).Copy Destination:=Worksheets("nom de site " & Cells(i, 1).Value).Cells(k + 1, 1)
Rows(i).Delete
i = i - 1
Case Is = "B"
k = Worksheets("nom de site " & Cells(i, 1).Value).Range("A" & Rows.Count).End(xlUp).Row
Range(Cells(i, 1), Cells(i, 9)).Copy Destination:=Worksheets("nom de site " & Cells(i, 1).Value).Cells(k + 1, 1)
Rows(i).Delete
i = i - 1
Case Is = "C"
k = Worksheets("nom de site " & Cells(i, 1).Value).Range("A" & Rows.Count).End(xlUp).Row
Range(Cells(i, 1), Cells(i, 9)).Copy Destination:=Worksheets("nom de site " & Cells(i, 1).Value).Cells(k + 1, 1)
Rows(i).Delete
i = i - 1
End Select
Else
End If
Next i
End Sub
Maybe with this code. You can enter "remove" in column J ( in one or many cells) and click the button in cell K1. The row then is copied to the designated sheet and then it is deleted from the "to do" sheet.
adrian_hafredal
Aug 30, 2022Copper Contributor
Didn't quite get it to work. attaching the parameters I must have in my workbook.
Parameter | Value |
first column to be moved | A |
Last column to be moved | L |
From sheet | I arbeid |
To sheet | Tone |
Column that determines relocation | L |
Value that triggers move | Tone |
Parameter | Verdi |
first column to be moved | A |
Last column to be moved | L |
From sheet | I arbeid |
To sheet | Jan Gunnar |
Column that determines relocation | L |
Value that triggers move | Jan Gunnar |
Parameter | Verdi |
first column to be moved | A |
Last column to be moved | L |
From sheet | I arbeid |
To sheet | Vivi-Ann |
Column that determines relocation | L |
Value that triggers move | Vivi-Ann |
- OliverScheurichAug 30, 2022Gold Contributor
I've adapted the macro to the requirements.
- adrian_hafredalAug 30, 2022Copper Contributor
- OliverScheurichAug 30, 2022Gold Contributor