View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
ordnance1[_2_] ordnance1[_2_] is offline
external usenet poster
 
Posts: 92
Default Search and replace problem

Can anyone tell me why my code below only deletes data from worksheet April
and not all of the selected worksheets? I intend that the TextBox1 value be
found on all selected worksheets and be replaced by nothing, in effect
removing the data from all worksheets.



Private Sub CommandButton1_Click()

x = TextBox1.Value

If ActiveSheet.Name = "April" Then

Sheets(Array("April", "May", "June", "July", "August",
"September")).Select

Cells.Replace What:=x, Replacement:="", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

Sheets("April").Select

End If

Unload UserForm1

End Sub