• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Code to delete row and appear on next sheet

Pasadu
I gave You two procedures in #9 reply.
You verified with #12 reply - how should this work?
... my code works as You've verified.
... and now with #19 You seems to change it again - why?
I could do that procedure at once - it was my second ( and more logical ) procedure, but You verified that other.
 
Pasadu
Now, with You the newest version is again different.
> There are more columns in SHIPMENT STATUS-sheet than You previous sample -- previous version works with less columns.
means: A sample layout should be same as real layout.
Ps. I tested to 'LOADED' with one row, that's why there is one row moved.
 

Attachments

  • 26.06.xlsm
    38.3 KB · Views: 3
And this edit to my original code works with your new layout.

To continue programming you must learn how to interpret the example code you are viewing and make the required changes
for your specific workbook. Relying on others to create code based on your descriptions and expecting everything to work
flawlessly is not reasonable. To complain about it afterwards is an insult.

May this experience be a learning opportunity for you.

Code:
Option Explicit

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 STATUS")
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
 
Pasadu
Now, with You the newest version is again different.
> There are more columns in SHIPMENT STATUS-sheet than You previous sample -- previous version works with less columns.
means: A sample layout should be same as real layout.
Ps. I tested to 'LOADED' with one row, that's why there is one row moved.
Thank You, Thank You, Thank You, Merci beaucoup. I have exactly what I need, thank You Vletm, i appreciate it and I'm sorry for the inconveniences. Thank You.
 
And this edit to my original code works with your new layout.

To continue programming you must learn how to interpret the example code you are viewing and make the required changes
for your specific workbook. Relying on others to create code based on your descriptions and expecting everything to work
flawlessly is not reasonable. To complain about it afterwards is an insult.

May this experience be a learning opportunity for you.

Code:
Option Explicit

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 STATUS")
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
Thank you Logit, I have what I need now, it works perfectly. Thank You.
 
Back
Top