Delete table row after cut / paste

Nuke_It_Newport

New Member
Joined
Nov 17, 2020
Messages
47
Office Version
  1. 365
Platform
  1. Windows
Hi everyone-

How do I pass the name of the sheet being deactivated to another module? I've tried setting a Public variable as String, Worksheet, and Object. I can't get any of these to work correctly. I need to delete a table row on the source sheet after a row is cut and pasted to a destination sheet.

VBA Code:
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
    
Debug.Print "Worksheet """ & Sh.Name & """ deactivated..."

End Sub

Thanks!
 
  • In the original code I posted above, I'm resizing the table using a static column of "S". I'd like to replace Range("A3:S" & lRow) with a Range starting at A3, ending at the last table row and column.
Code:
tbl.Resize .Range("A3:S" & lRow)
For this one, the following should work:

VBA Code:
    Dim lCol As Long
    With ws
        lRow = .Range("A" & Rows.Count).End(xlUp).Row
        lCol = tbl.Range.Cells(1, 1).End(xlToRight).Column
        tbl.Resize .Range(tbl.Range.Cells(1, 1), .Cells(lRow, lCol))
    End With


  • In Workbook_SheetSelectionChange, I'm using the following to highlight the active row. I would like to limit this to the table columns.
Code:
With Target.EntireRow.FormatConditions.Add(Type:=xlExpression, Formula1:="=TRUE")
.SetFirstPriority
.Interior.Color = 10092543
End With

You might need to do a new thread for this one.
You would need to show all or more the code. eg does your code ensure that the Target cell is in the table bounds. Have you set a table object that can be used ?
eg if you had set tbl as in this code you could use the same intersect code.
VBA Code:
    With Intersect(Target.EntireRow, tbl.Range).FormatConditions.Add(Type:=xlExpression, Formula1:="=TRUE")
        .SetFirstPriority
        .Interior.Color = 10092543
    End With
 
Upvote 0
Solution

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
For this one, the following should work:

VBA Code:
    Dim lCol As Long
    With ws
        lRow = .Range("A" & Rows.Count).End(xlUp).Row
        lCol = tbl.Range.Cells(1, 1).End(xlToRight).Column
        tbl.Resize .Range(tbl.Range.Cells(1, 1), .Cells(lRow, lCol))
    End With




You might need to do a new thread for this one.
You would need to show all or more the code. eg does your code ensure that the Target cell is in the table bounds. Have you set a table object that can be used ?
eg if you had set tbl as in this code you could use the same intersect code.
VBA Code:
    With Intersect(Target.EntireRow, tbl.Range).FormatConditions.Add(Type:=xlExpression, Formula1:="=TRUE")
        .SetFirstPriority
        .Interior.Color = 10092543
    End With
Thank you so much! You've been most helpful. I have set a table object,
For this one, the following should work:

VBA Code:
    Dim lCol As Long
    With ws
        lRow = .Range("A" & Rows.Count).End(xlUp).Row
        lCol = tbl.Range.Cells(1, 1).End(xlToRight).Column
        tbl.Resize .Range(tbl.Range.Cells(1, 1), .Cells(lRow, lCol))
    End With




You might need to do a new thread for this one.
You would need to show all or more the code. eg does your code ensure that the Target cell is in the table bounds. Have you set a table object that can be used ?
eg if you had set tbl as in this code you could use the same intersect code.
VBA Code:
    With Intersect(Target.EntireRow, tbl.Range).FormatConditions.Add(Type:=xlExpression, Formula1:="=TRUE")
        .SetFirstPriority
        .Interior.Color = 10092543
    End With
Thank you! The first code snippet works perfect. For the second code snippet, I do have a table object. I quickly learned what you mean about the need to check if the target is within the table range. I think I can figure that one out with the info you've given me. If not, I'll start a new thread. Thanks for your help!
 
Upvote 0

Forum statistics

Threads
1,214,793
Messages
6,121,614
Members
449,039
Latest member
Mbone Mathonsi

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