Macro to cut entire row form table depending on the value of column "M" and paste on another table

GabyS2023

New Member
Joined
Nov 27, 2023
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Can someone help me rewrite this macro that I recorded? I want the entire row to delete from Table "HL" when value in column M = "Ready to ticket" and paste entire row in Table "RT" in same sheet.
VBA Code:
Sub Readytoticket()
'
' Readytoticket Macro
'
' Keyboard Shortcut: Ctrl+Shift+T
'
    Range("B259:AA259").Select
    Selection.Cut
    Range("B234").Select
    ActiveSheet.Paste
    Range("B259:AA259").Select
    Selection.ListObject.ListRows(11).Delete
End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
It would have helped if you could have posted what your sheet looks like, however, I've based this on your existing code assuming that your HL table starts in column B, and therefore 'column M' would be field 12 of your table. Please try this on a copy of your workbook.
VBA Code:
Option Explicit
Sub Ready_to_ticket()
    Dim Lob1 As ListObject, Lob2 As ListObject, DestRow As ListRow
    Set Lob1 = ActiveSheet.ListObjects("HL")
    Set Lob2 = ActiveSheet.ListObjects("RT")
    Set DestRow = ActiveSheet.ListObjects("RT").ListRows.Add
    
    With ActiveSheet
        .ListObjects("RT").AutoFilter.ShowAllData
        With .ListObjects("HL")
            .AutoFilter.ShowAllData
            .Range.AutoFilter 12, "Ready to ticket"
            With .DataBodyRange.SpecialCells(xlCellTypeVisible)
                .Copy DestRow.Range
                '.EntireRow.Delete          '<-- un-comment this if you also want the row to be deleted
            End With
            .AutoFilter.ShowAllData
        End With
    End With
End Sub
 
Upvote 0
It would have helped if you could have posted what your sheet looks like, however, I've based this on your existing code assuming that your HL table starts in column B, and therefore 'column M' would be field 12 of your table. Please try this on a copy of your workbook.
VBA Code:
Option Explicit
Sub Ready_to_ticket()
    Dim Lob1 As ListObject, Lob2 As ListObject, DestRow As ListRow
    Set Lob1 = ActiveSheet.ListObjects("HL")
    Set Lob2 = ActiveSheet.ListObjects("RT")
    Set DestRow = ActiveSheet.ListObjects("RT").ListRows.Add
   
    With ActiveSheet
        .ListObjects("RT").AutoFilter.ShowAllData
        With .ListObjects("HL")
            .AutoFilter.ShowAllData
            .Range.AutoFilter 12, "Ready to ticket"
            With .DataBodyRange.SpecialCells(xlCellTypeVisible)
                .Copy DestRow.Range
                '.EntireRow.Delete          '<-- un-comment this if you also want the row to be deleted
            End With
            .AutoFilter.ShowAllData
        End With
    End With
End Sub
Hello! Thank your reply :), it only seems to hide all rows from the table "HL", here is a image of how it looks. Unfortunately my team wants both tables in the same sheet so having them separate is not an option lol, again thank you so much
1701813607821.png
 
Upvote 0
The code worked on a mockup I created to test the code.
If you're willing to share your actual file via Google Drive, Dropbox or similar file sharing platform - then I'll be willing to look at it again. Otherwise, I'll leave it to others to discern what's causing the problem.
 
Upvote 0

Forum statistics

Threads
1,215,077
Messages
6,122,992
Members
449,094
Latest member
masterms

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top