Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace Function not Working

Status
Not open for further replies.

tekniks

Technical User
Jun 27, 2003
98
US
I have the following code which was working before but has stopped working since my upgrade to the Windows 2000 environment from NT 4.0:

Private Function Compare_Copy_Sheet(ws1 As Worksheet, ws2 As Worksheet) As String

With ws1
.Activate
.Unprotect
.Cells(R, 2).Replace _
what:=Stat_val, Replacement:=cstsStat_val, _
SearchOrder:=xlByColumns, MatchCase:=False
.Cells(R, 2).Interior.ColorIndex = 43
.Cells(R, 2).Borders.ColorIndex = 15
.Cells(R, 2).Font.ColorIndex = 1
End With

where Stat_Val is Value in Sheet1(ws1) and cstsStat_val is value in Sheet2(ws2)
The strange thing is that only the Replace function doesn't work and the lines after Replace work. There is no error generated.

Any ideas as to why?

TKS

Teks
 
tekniks,

You have soem stuff goin on here that does not look good.

First you state, "where Stat_Val is Value in Sheet1(ws1) and cstsStat_val is value in Sheet2(ws2)"

Where are Stat_Val and cstsStat_val passed to this function?

You have 2 worksheet objects passed but only use ws1???



Skip,
Skip@TheOfficeExperts.com
 
Skip,

I am passing them discretely through the code below which I intentionally did not paste for the sake of brevity:
Stat_val = ws1.Cells(R, 2).Value
cstsStat_val = ws2.Cells(RowNum, 2).Value

Teks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top