Find Variable Delete Selection

joeyjj

Board Regular
Joined
Aug 12, 2010
Messages
62
Hello all,

I am trying to design a macro which will delete the active cell as well as the details of that active cell on a separate sheet. The data is organized in the following manner on the main sheet:

ColA ColB ColC ColD ColE

1 Data 25 25 25

And on the detail sheet its organized as follows:

ColA ColB ColC ColD ColE

1
Data
25
25
25

Basically I want to search for the number on top labelled as 1 (not always 1 could be 2 or 20) and delete the entire row from the main sheet and delete all the rows that contain the same data in the detail sheet.

Please note that there will be additional information above and below the data sets in both sheets, however, the data of question is separated by a blank row.

I have the following coding which does not work and I am trying to figure out the best approach:

PHP:
Sub Delete_Section_click()

Dim ws As Worksheet
Set ws = Worksheets("Report")
Dim Dws As Worksheet
Set Dws = Worksheets("Detail_Data")
Dim VFind As Range

VFind = ActiveCell.Value
VFind.EntireRow.Delete
Dws.Select

Cells.Find(VFind, after:=ActiveCell, LookIn:=xlValues, LookAt:= _
        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False).Activate
Range(VFind, Cells(Rows.Count, VFind.Column).End(xlUp)).Select

EntireRow.Delete

End Sub

Any help is appreciated.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
I found the work around it was

PHP:
Sub Delete_Section_click()

Dim ws As Worksheet
Set ws = Worksheets("Report")
Dim Dws As Worksheet
Set Dws = Worksheets("Detail_Data")

VFind = ActiveCell.Value
Selection.EntireRow.Delete
Dws.Select

Cells.Find(VFind, After:=ActiveCell, LookIn:=xlValues, LookAt:= _
        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False).Activate
Selection.CurrentRegion.Select

Selection.EntireRow.Delete

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,504
Messages
6,179,144
Members
452,891
Latest member
JUSTOUTOFMYREACH

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