Results 1 to 11 of 11

Need help replacing values in multiple cells

Threaded View

  1. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Need help replacing values in multiple cells

    Well, it works on your sample

    Sub PhilW(): Dim UR As Range, n As Long, m As Long
    Dim C As Range, S As String, Q As String
    Set UR = ActiveSheet.UsedRange
    For Each C In UR: S = C.Value
    n = InStr(1, S, "Birthday")
    If n = 0 Then GoTo NextCell
    m = InStrRev(S, " ", n - 3) + 1
    Q = Mid(S, m, n - m - 3)
    If IsNumeric(Q) Then
    Mid(S, m, n - m - 3 + 1) = CStr(Val(Q) + 1)
    C.Value = S: End If
    NextCell: Next
    UR.Replace "0h", "0th"
    UR.Replace "1th", "1st"
    UR.Replace "2th", "2nd"
    UR.Replace "3th", "3rd"
    UR.Replace "2st", "2nd"
    UR.Replace "3nd", "3rd"
    UR.Replace "4rd", "4th"
    End Sub

    Directions for running the routine(s) just supplied

    If you haven't used macros before you'll need to go to:
    File- options - trust center -trust center settings - macro settings ,
    the second option down (disable all macros with notification)

    Then - Copy the code to the clipboard

    Open your Workbook

    Press ALT + F11 to open the Visual Basic Editor.

    Select "Module" from the Insert menu

    Type "Option Explicit" then paste the code under it

    With the cursor between Sub and End Sub press F5 (F8 to Single Step)

    OR

    Press ALT + Q to close the code window.

    Press ALT + F8 then double click on the macro name
    *Be sure to save the book with the code as Macro-Enabled
    Last edited by xladept; 03-08-2017 at 06:26 PM. Reason: Details:)
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Finding and Replacing multiple values at a time
    By sandubandu in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-15-2016, 03:35 AM
  2. finding and replacing multiple values
    By cheoksoon in forum Excel General
    Replies: 15
    Last Post: 06-15-2014, 11:12 AM
  3. Replacing the NA values with blank cells
    By JPSIMMON in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-26-2013, 01:28 PM
  4. Find and replacing multiple values VBA
    By Hutton34 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-25-2012, 06:38 AM
  5. Replies: 6
    Last Post: 07-06-2006, 04:15 PM
  6. Help needed replacing multiple cells from a list of values.
    By Emoshag in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-06-2006, 12:35 PM
  7. Replacing Values in Cells Via Formula
    By pclutts in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-10-2005, 09:21 AM

Tags for this Thread

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