Hey!
Hoping for some help once again.
I have a table that tracks my rentals:
I would like it so that when a button is pushed, any rows that have the rental marked as "Returned" in the last Column (Column M)
would be completely cut from that table
and Pasted onto another table on a different sheet. (The paste has to go into the table, so maybe "Insert copied cells"? )
It has to be removed from the first table completely, we can delete the entire row if that's easier.
I am really not sure why I am having such a hard time with this one.
Sheet with the first able on it: "Rental Tracker"
Second sheet we want to cut it into "Rental MTLink"
Here is some code I have tried:
That is close, but it does not paste it into the table on the other sheet, it pastes it right below it.
This one doesn't work at all.
I clearly still dont know how to write code in VBA, so any help you can offer is appreciated!
Hoping for some help once again.
I have a table that tracks my rentals:
Job Number: | Job Name: | Equipment rented: | Employee: | Company Rented from: | Rental Start Date: | Length of rental | Estimated Due Date: | Date Returned: | Returned By: | Total cost of the rental: | Rental Complete | |
Scissor lift | 3/25/2022 | 1 | Week(s) | 4/1/2022 |
I would like it so that when a button is pushed, any rows that have the rental marked as "Returned" in the last Column (Column M)
would be completely cut from that table
and Pasted onto another table on a different sheet. (The paste has to go into the table, so maybe "Insert copied cells"? )
It has to be removed from the first table completely, we can delete the entire row if that's easier.
I am really not sure why I am having such a hard time with this one.
Sheet with the first able on it: "Rental Tracker"
Second sheet we want to cut it into "Rental MTLink"
Here is some code I have tried:
VBA Code:
Sub returnstep1()
Dim c As Range
Dim Source As Worksheet
Dim Target As Worksheet
Set Source = ActiveWorkbook.Worksheets("Rental Tracker")
Set Target = ActiveWorkbook.Worksheets("Rental MTLink")
For Each c In Source.Range("M3:M" & Source.Cells(Rows.Count, 1).End(xlUp).Row)
If c = "Returned" Then
c.EntireRow.Copy
Target.Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValues
End If
Next c
End Sub
That is close, but it does not paste it into the table on the other sheet, it pastes it right below it.
This one doesn't work at all.
Code:
Sub ReturnStep1Broken()
'
' ReturnButton Macro
Sheets("Rental Tracker").Select
Sheets("Rental MTLink").Visible = True
Sheets("Rental Tracker").Select
Set Rng = Range("M3" & Cells(ActiveSheet.Rows.Count, "A").End(xlUp).Row)
For i = Rng.Cells.Count To 1 Step -1
If Rng(i).Value = "Returned" Then Range(Rng(i).EntireRow).Copy
Sheets("Rental MTLink").Select
Rows("3:3").Select
Selection.Insert Shift:=xlDown
Application.CutCopyMode = False
Sheets("Rental Tracker").Select
If Rng(i).Value = "Returned" Then Range(Rng(i).EntireRow).Delete
Next i
End Sub
I clearly still dont know how to write code in VBA, so any help you can offer is appreciated!