Sub MoveMyrow()
Dim Sh1 As Worksheet, sh2 As Worksheet
Dim lrsh1 As Long, lrsh2 As Long
Dim mRng As Range
Dim x As Integer
Set Sh1 = ThisWorkbook.Sheets("Shipment")
Set sh2 = ThisWorkbook.Sheets("Loading Status")
lrsh1 = Sh1.Cells(Rows.Count, 1).End(xlUp).Row
lrsh2 = sh2.Cells(Rows.Count, 1).End(xlUp).Row
Set mRng = Sh1.Range("A2:A" & lrsh1)
For x = 2 To mRng.Count
If CStr(mRng(x).Value) = "Loaded" Then
mRng(x).EntireRow.Copy Destination:=sh2.Range("A2:A" & lrsh2)
mRng(x).EntireRow.Delete
If CStr(mRng(x).Value) = "LOADED" Then
x = x - 1
End If
End If
Next
End Sub
Thank you but it did not work. Please find file attachedTry the following. It searches COL A for the term LOADED.
Code:Sub MoveMyrow() Dim Sh1 As Worksheet, sh2 As Worksheet Dim lrsh1 As Long, lrsh2 As Long Dim mRng As Range Dim x As Integer Set Sh1 = ThisWorkbook.Sheets("Shipment") Set sh2 = ThisWorkbook.Sheets("Loading Status") lrsh1 = Sh1.Cells(Rows.Count, 1).End(xlUp).Row lrsh2 = sh2.Cells(Rows.Count, 1).End(xlUp).Row Set mRng = Sh1.Range("A2:A" & lrsh1) For x = 2 To mRng.Count If CStr(mRng(x).Value) = "Loaded" Then mRng(x).EntireRow.Copy Destination:=sh2.Range("A2:A" & lrsh2) mRng(x).EntireRow.Delete If CStr(mRng(x).Value) = "LOADED" Then x = x - 1 End If End If Next End Sub
Sub MoveMyrow()
Dim Sh1 As Worksheet, sh2 As Worksheet
Dim lrsh1 As Long, lrsh2 As Long
Dim mRng As Range
Dim x As Integer
Set Sh1 = ThisWorkbook.Sheets("SHIPMENT")
Set sh2 = ThisWorkbook.Sheets("LOADING STATUS")
lrsh1 = Sh1.Cells(Rows.Count, 1).End(xlUp).Row
lrsh2 = sh2.Cells(Rows.Count, 1).End(xlUp).Row
Set mRng = Sh1.Range("A2:A" & lrsh1)
For x = 2 To mRng.Count
If CStr(mRng(x).Value) = "LOADED" Then
mRng(x).EntireRow.Copy Destination:=sh2.Range("A2:A" & lrsh2).Offset(1, 0)
mRng(x).EntireRow.Delete
If CStr(mRng(x).Value) = "LOADED" Then
x = x + 1
End If
End If
Next
End Sub
I appreciate your support, but it isnt really working as it should. Somehow it copies onto the other sheet but it doesnt delete the row. Also, it copies partially, it isn't instantThis works here :'
Code:Sub MoveMyrow() Dim Sh1 As Worksheet, sh2 As Worksheet Dim lrsh1 As Long, lrsh2 As Long Dim mRng As Range Dim x As Integer Set Sh1 = ThisWorkbook.Sheets("SHIPMENT") Set sh2 = ThisWorkbook.Sheets("LOADING STATUS") lrsh1 = Sh1.Cells(Rows.Count, 1).End(xlUp).Row lrsh2 = sh2.Cells(Rows.Count, 1).End(xlUp).Row Set mRng = Sh1.Range("A2:A" & lrsh1) For x = 2 To mRng.Count If CStr(mRng(x).Value) = "LOADED" Then mRng(x).EntireRow.Copy Destination:=sh2.Range("A2:A" & lrsh2).Offset(1, 0) mRng(x).EntireRow.Delete If CStr(mRng(x).Value) = "LOADED" Then x = x + 1 End If End If Next End Sub
It doesn't work as I want. However, I still appreciate your effort sir, I am indeed grateful.Not certain what to advise. The macro does work here as intended.
Everything is typed, it is manual.Pasadu
Verify Your written steps:
#1 Loaded
#2 Delete
#3 Move
above means:
#1 if cell A4 get 'Loaded'
#2 delete that row 4 - which have 100E | 7 | 40FT | PAPER
#3 move row, which has 600U | 8 | 20FT | PAPER to LOADING STATUS-sheet
... above means that row will be empty in SHIPMENT-sheet.
OR
something like below:
#1 if cell A4 get 'Loaded'
#2 move row 4 - which have Loaded | 100E | 7 | 40FT | PAPER to LOADING STATUS-sheet
... above means that row will be empty in SHIPMENT-sheet.
How do that 'Loaded' appears in STATUS-column?
... do someone write it?
... is there eg link to somewhere?
The final goal is for the entire row to be moved to the next sheet whenever CLEARED appears in columA in any row.Did I misunderstand what the final goal is ?
This is whati need please:Pasadu
Verify Your written steps:
#1 Loaded
#2 Delete
#3 Move
above means:
#1 if cell A4 get 'Loaded'
#2 delete that row 4 - which have 100E | 7 | 40FT | PAPER
#3 move row, which has 600U | 8 | 20FT | PAPER to LOADING STATUS-sheet
... above means that row will be empty in SHIPMENT-sheet.
OR
something like below:
#1 if cell A4 get 'Loaded'
#2 move row 4 - which have Loaded | 100E | 7 | 40FT | PAPER to LOADING STATUS-sheet
... above means that row will be empty in SHIPMENT-sheet.
How do that 'Loaded' appears in STATUS-column?
... do someone write it?
... is there eg link to somewhere?
Thank you sir, , the row deletes perfectly from the Shipment Sheet....But it does not necessarily appear on the Loading Status sheet. All the contents on that deleted row, should all appear in the "loading status sheet". Thank YouPasadu
SHIPMENT-sheet has Your verified delete row and appear on next sheet-sample.
LOADING STATUS-sheet has Your verified delete entire row-sample.
(( https://chandoo.org/forum/threads/code-to-delete-entire-row.48215/ ))
Have a backups.
Thank you sir, , the row deletes perfectly from the Shipment Sheet....But it does not necessarily appear on the Loading Status sheet
Oh, interesting. But i really appreciate your effortsvletm:
He has now experienced an issue with your example and mine. I suggest there is something going on with his installed copy of EXCEL.
Yes you are right. The row deletes but the other sheet isn't updated successfully. With Vlet's file, the other sheet updates but not perfectly even though it updates.Please explain ... both my version and vletm's version successfully delete the information from the first sheet but fail to always paste as expected to the second sheet.
How is the above satisfactory to your needs ? On your end, you only have half a solution. On our ends, there is a complete solution.
How can you be pleased ?
Help me understand.
I haven't created the workbook yet. Once I understand the code, I can design the workbook. But for now, I don't have the workbook, just a picture of what I want to do, in my mindPlease attach your workbook for review.
No, don't get me wrong. I attached a workbook where you helped me with the code. However, I will use these codes through many other workbooks.If you dont have a workbook yet ... how do you know the code doesn't work ?
Your actions and replies are all indicative of a FORUM TROLL. The volunteers on this and other forums willing donate their
time and efforts free of charge. Most volunteers are gainfully employed so their efforts here are completed when they have
some free time from their employers needs.
What you are doing is 'playing' with the volunteers which is not appreciated.
Best wishes on securing an answer.
Volunteers beware !
Alright, I'll do so.Attach the workbook that isn't working with either macro code.