+ Reply to Thread
Results 1 to 3 of 3

Replace with wildcards

  1. #1
    Registered User
    Join Date
    07-14-2006
    Posts
    15

    Replace with wildcards

    Is it possible, and if so, how do I go about creating a find/replace statement that will apend text after a wild card statement?
    I have a table of IP addresses, I need to append designators onto some of the addresses. How can I make a single find replace that would accomplish it:

    192.168.0.15 ==> 192.168.0.15 Private
    192.168.10.8 ==> 192.168.10.8 Private

  2. #2
    Forum Contributor
    Join Date
    03-12-2004
    Posts
    147
    Why not concatenate the cells? Perhaps you could find some logical criteria to sort the IP addresses into ones that should be made private, then concatenate...

    For example:

    Column A has the IP address
    Column B has the word "Private"

    In column C enter the following formula =A1&" "&B1
    Your result would give you what you are looking for.

    If the only word you will use is private than just enter this formula into column B:

    =A1&" Private"

  3. #3
    Registered User
    Join Date
    07-14-2006
    Posts
    15
    Unfortunately, The full spread sheet is made of two column sets, each representing a day, with lists of IP addresses in the first column and a value in the second column. The values and IP addresses change daily. So, Columns A and B represent Monday, C and D Tuesday, etc. I need so way for a find replace to include wild cards and append a value while leaving the wildcard statement intact. Currently some specific IP addresses are changed via a macro, as follows

    Sub DestSpecialFormats()

    Dim rngFound As Range
    Dim rngFoundAll As Range
    Dim strFirstAddress As String
    Dim wks As Worksheet
    Dim rngToSearch As Range

    Set wks = Sheets("Top Dest IPs")
    Set rngToSearch = wks.Cells
    Set rngFound = rngToSearch.Find(What:=" 192.168.0.1", _
    LookIn:=xlFormulas, _
    LookAt:=xlWhole, _
    MatchCase:=False)
    If rngFound Is Nothing Then

    Else
    Set rngFoundAll = rngFound
    strFirstAddress = rngFound.Address
    Do
    Set rngFoundAll = Union(rngFound, rngFoundAll)
    Set rngFound = rngToSearch.FindNext(rngFound)
    Loop Until rngFound.Address = strFirstAddress
    wks.Select
    rngFoundAll.Select
    With Selection.Interior
    .ColorIndex = 39
    .Pattern = xlSolid
    Selection.FormulaR1C1 = " 192.168.0.1 Home"
    Selection.FormatConditions.Delete
    End With
    End If

    End Sub

    The same statement is repeated for every address that needs altered. I need to be able to use the same statement to use across ranges instead, keeping the actual values intact.
    So, something that would look like this, but work, because this doesn't...

    Set rngFound = rngToSearch.Find(What:=" 192.*.*.*", _

    Selection.FormulaR1C1 = " 192.*.*.* Home"

    Changing the macro like this replaces at 192.*.*.* (as the wild cards indicate) with the actual statement '192.*.*.* Home' as the wild cards in the 'replace' section are literal and not actual wildcards.

+ 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