moonlight22
New Member
- Joined
- Aug 15, 2014
- Messages
- 24
Hello,
I have recorded a macro which I've modifed to accomplish what I want.
Basically I have a 2 worksheets.
ControlSheet : which has a cell that contains my "criteria" and a button to run the macro
DataSheet: Which holds that data that will be modified based on the macro.
The user is able to enter a value into Cell B3 withing ControlSheet, and when the button his pressed, the row that contains this value in DataSheet is supposed to be deleted.
My macro works, however, this macro only removes one row at a time. Because the value the user entered can appear more than once in the DataSheet, I need all rows that have a cell which contains that value detleted.
I'm unsure how to loop the function in my macro which finds and then deletes the row.
Any help would be great!
(note: there are a couple other actions that are completed at the end of my macro which are part of my requirments but they dont need any modification)
This is my macro:
Sub RR()
'
' RR Macro
'
'
Range("B3").Select
Selection.Copy
Sheets("DataSheet").Select
Cells.Find(what:=Worksheets("ControlSheet").Range("B3").Value, After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
Selection.EntireRow.Delete
Range("A1").Select
Sheets("ControlSheet").Select
Selection.Cut
Range("B8").Select
ActiveSheet.Paste
Range("B3").Select
End Sub
I have recorded a macro which I've modifed to accomplish what I want.
Basically I have a 2 worksheets.
ControlSheet : which has a cell that contains my "criteria" and a button to run the macro
DataSheet: Which holds that data that will be modified based on the macro.
The user is able to enter a value into Cell B3 withing ControlSheet, and when the button his pressed, the row that contains this value in DataSheet is supposed to be deleted.
My macro works, however, this macro only removes one row at a time. Because the value the user entered can appear more than once in the DataSheet, I need all rows that have a cell which contains that value detleted.
I'm unsure how to loop the function in my macro which finds and then deletes the row.
Any help would be great!
(note: there are a couple other actions that are completed at the end of my macro which are part of my requirments but they dont need any modification)
This is my macro:
Sub RR()
'
' RR Macro
'
'
Range("B3").Select
Selection.Copy
Sheets("DataSheet").Select
Cells.Find(what:=Worksheets("ControlSheet").Range("B3").Value, After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
Selection.EntireRow.Delete
Range("A1").Select
Sheets("ControlSheet").Select
Selection.Cut
Range("B8").Select
ActiveSheet.Paste
Range("B3").Select
End Sub