+ Reply to Thread
Results 1 to 8 of 8

problem with replace command

  1. #1
    ruchie
    Guest

    problem with replace command

    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


  2. #2
    Chip Pearson
    Guest

    Re: problem with replace command

    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


    "ruchie" <ruchie.sharma@gmail.com> wrote in message
    news:1153772636.865756.49450@p79g2000cwp.googlegroups.com...
    > 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
    >




  3. #3
    Tom Hutchins
    Guest

    RE: problem with replace command

    You defined x as an integer. Integers don't up to 40000. Change it to a Long.

    Hope this helps,

    Hutch

    "ruchie" wrote:

    > 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
    >
    >


  4. #4
    Chip Pearson
    Guest

    Re: problem with replace command

    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


    "ruchie" <ruchie.sharma@gmail.com> wrote in message
    news:1153772636.865756.49450@p79g2000cwp.googlegroups.com...
    > 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
    >




  5. #5
    Tom Hutchins
    Guest

    RE: problem with replace command

    You defined x as an integer. Integers don't up to 40000. Change it to a Long.

    Hope this helps,

    Hutch

    "ruchie" wrote:

    > 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
    >
    >


  6. #6
    ruchie
    Guest

    Re: problem with replace command

    thanks a ton Chip! it worked now!!!


  7. #7
    ruchie
    Guest

    Re: problem with replace command

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

    should this work to replace blanks as well?


  8. #8
    Bob Phillips
    Guest

    Re: problem with replace command

    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)

    "ruchie" <ruchie.sharma@gmail.com> wrote in message
    news:1153774592.466650.312950@75g2000cwc.googlegroups.com...
    > Cells(x, 25).Value = Replace(Cells(x, 25).Value, "", "TRU")
    >
    > should this work to replace blanks as well?
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1