Results 1 to 3 of 3

Find and replace with criteria - VBA code

Threaded View

  1. #2
    Valued Forum Contributor Hawkeye16's Avatar
    Join Date
    02-27-2013
    Location
    Holland
    MS-Off Ver
    ├•┤ Pew Pew
    Posts
    441

    Re: Find and replace with criteria - VBA code

    If there are no blank rows in the data you could use

    dim i as integer
    i = 0
    do while Range("C1").offset(i,0).value <> ""
    If Range("C1").offset(i,0).Value > 5 Then
    
        Range("B1").offset(i,0).Select
        Selection.Replace What:="SERIES", Replacement:="", LookAt:=xlPart, _
            SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
            ReplaceFormat:=False
            Else
            MsgBox ("NO DATA FOUND")
     End If
    i = i + 1
    loop
    If there are blank rows you could use something like

    dim i, r as integer
    r = range("c"&rows.count).end(xlup).row
    for i = 0 to r
    If Range("C1").offset(i,0).Value > 5 Then
    
        Range("B1").offset(i,0).Select
        Selection.Replace What:="SERIES", Replacement:="", LookAt:=xlPart, _
            SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
            ReplaceFormat:=False
            Else
            MsgBox ("NO DATA FOUND")
     End If
    next
    edit: Second one is tested. You will get a message box for ever row that does not have data so you may want to take that out.
    Last edited by Hawkeye16; 07-23-2014 at 03:53 AM.
    Despite the high cost of living, it remains very popular.

    Don't forget to mark threads SOLVED when you get an answer and rep all the geniouses that helped you today!

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] vba code to replace old values by new value with 2 type of criteria
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-19-2014, 03:31 AM
  2. Find and replace with criteria
    By Jhon Mustofa in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 01-07-2014, 01:52 AM
  3. [SOLVED] Find and replace using cell contents as the search criteria
    By Vlad717 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-08-2013, 03:58 PM
  4. Find and Replace code help
    By missy22 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-24-2013, 08:32 AM
  5. Find and replace in VBA Code
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-15-2012, 01:33 PM

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