View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Javed Javed is offline
external usenet poster
 
Posts: 91
Default Search and replace problem

On Apr 16, 3:35*pm, joel wrote:
there are too many things wrong in VBA to attempt an explanation when
VBA doesn't work the way you expect. *In this case, it is just better to
use good programming style and change the code as follows

Private Sub CommandButton1_Click()

ShtNames = Array("April","June","July","August","September")

x = TextBox1.Value

for each shtname in ShtNames
Set Sht = sheets(shtname)

Sht.Cells.Replace What:=x, Replacement:="", _
LookAt:=xlWhole, _
ReplaceFormat:=False
next sht

Unload UserForm1

End Sub

--
joel
------------------------------------------------------------------------
joel's Profile:http://www.thecodecage.com/forumz/member.php?u=229
View this thread:http://www.thecodecage.com/forumz/sh...d.php?t=196113

http://www.thecodecage.com/forumz



One argument is there in Replace method of Range
Searchwithin:=xlsearchwithinworkbook.
If you add this then the replacement will be for entire workbook.