Share via

Deleting same rows on two different sheets

Anonymous
2011-11-12T14:25:39+00:00

I have a workbook with 2 sheets named Contributors and Weekly_Contributions. I have a menu that has a command button "Delete Contributor". When this button is selected I want a msg that says "To delete contributor hold down the Ctrl key and select the row numbers of all contributors you wish to delete. Then if possible press the delete key (or another button) to delete the selected rows on the Contributors sheet PLUS the same rows on the Weekly_Contribution sheet. This must work in Excel 03, 07, and 10. also XP thru Win7

Oldjay

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2011-11-12T15:25:40+00:00

Sub RowRemover1()

MsgBox "Select your rows and then  run RowRemover2"

End Sub

Sub RowRemover2()

addy = Intersect(Selection, Range("A:A")).Address

With Worksheets("Contributors")

    .Range(addy).EntireRow.Delete

End With

With Worksheets("Weekly_COntributions")

    .Range(addy).EntireRow.Delete

End With

End Sub

Was this answer helpful?

0 comments No comments

5 additional answers

Sort by: Most helpful
  1. Anonymous
    2011-11-12T16:03:37+00:00

    Hi,

    Let's say that you want

    to delete the 5th row from

    sheet1 and sheet2

    (change Sheet1 and Sheet2 names as yours)

    make a copy first

    Right-click the Sheet1 tab > select  View code

    and paste the code below

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

    Dim ws As Worksheet

    Dim x As Long

    Set ws = Sheets("Sheet2")

    If Not Intersect(Target, Columns(1)) Is Nothing Then

    x = Target.Row

    Rows(x).Delete

    ws.Rows(x).Delete

    End If

    End Sub

    Just press double click on Sheet1

    in cell A5 (or in any other cell, in column A)

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2011-11-12T15:21:30+00:00

    Also you note that the rows on the Weekly_Contribution sheet have to be selected automatically based on what rows have been selected on the Contributors sheet.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2011-11-12T15:06:46+00:00

    " Then if possible press the delete key (or another button) to delete the selected rows on the Contributors sheet PLUS the same rows on the Weekly_Contribution sheet.

    Will your sub delete rows on both sheets?

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2011-11-12T14:43:47+00:00

    Once the rows have been selected, deleting them is easy:

    Sub dural()

    Selection.EntireRow.Delete

    End Sub

    How do you want the user to inform the macro that they are done selecting rows??

    Was this answer helpful?

    0 comments No comments