problem with replace command

  • Thread starter Thread starter ruchie
  • Start date Start date
R

ruchie

in this macro i am trying to find and replace data in the rows of a
particular column (25th). can someone guide me where im going wrong?

Sub ReplaceData()
Dim x As Integer
For x = 2 To 40000
Cells(x, 25).Select
cell.Value = Replace(cell.Value, "FALSE", "FAL")

Next x
End Sub



this code gives an overflow error
 
Try

Sub ReplaceData()
Dim x As Long
For x = 2 To 40000
Cells(x, 25).Value = Replace(Cells(x, 25).Value, "FALSE",
"FAL")
Next x
End Sub




--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
You defined x as an integer. Integers don't up to 40000. Change it to a Long.

Hope this helps,

Hutch
 
Cells(x, 25).Value = Replace(Cells(x, 25).Value, "", "TRU")

should this work to replace blanks as well?
 
If IsEmpty(Cells(x, 25).Value) Then Cells(x, 25).Value = "TRU"

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top