Not doing what it is suppose to do

joeyjj

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

I have the following code:

PHP:
Sub Delete_Section_click()

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

VFind = ActiveCell.Value
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
ws.Select
Selection.EntireRow.Delete

End Sub

This code show look at the number that is on the active cell set that number as a variable; VFind. Then it needs to look onto worksheet Details, find the number on sheet Details and delete the CurrentRegion.

The code runs fine except it does not delete the right selection. For example if the number in selected cell is 1 it deletes 3. I don't understand why and any advice or help is much appreciated. Thank you!
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Code:
Cells.Find(VFind, After:=ActiveCell, LookIn:=xlValues, [COLOR="Red"]LookAt:= xlWhole[/COLOR] _ 
        , SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _ 
        , SearchFormat:=False).Activate
 
Upvote 0

Forum statistics

Threads
1,224,505
Messages
6,179,152
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