+ Reply to Thread
Results 1 to 4 of 4

Macro Changing Text in a Cell Based on Text in Another

  1. #1
    Registered User
    Join Date
    11-21-2018
    Location
    US
    MS-Off Ver
    2017
    Posts
    2

    Macro Changing Text in a Cell Based on Text in Another

    Hello,
    I'm looking for help with a macro(s) that changes the text of one cell based on the text of another as well as changing the content of some cells based on their own content.

    Example
    If the text in Row B is "TextA," "TextB," or "TextC", it would need to return "Text1" in Row A; if the text in Row B is "TextD," then it would need to return "Text2" in Row A; and if the text is "TextE" it would need to return "Text3" to row A.
    If the text in Row A is "TextA1" then that cell text would need to be changed to "TextB"

    I've been working off what I know about creating macros that change the formatting based on the value of another cell, thinking I could just adjust accordingly, but with no luck.

    Thank you!

  2. #2
    Forum Contributor
    Join Date
    04-11-2012
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    245

    Re: Macro Changing Text in a Cell Based on Text in Another

    Hi -

    First, rows are referred to by number... row 1 row 2, etc. Not row A, row B, etc. That said, the following code checks the values in cells A2 thru A5 and if it finds TextA, TextB or TextC, it will populate Text1 to cell A1. Hope this helps!

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    04-11-2012
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    245

    Re: Macro Changing Text in a Cell Based on Text in Another

    Ooops. Missed your point. Try the following instead.

    Please Login or Register  to view this content.
    Last edited by Grilleman; 06-14-2019 at 02:00 PM.

  4. #4
    Registered User
    Join Date
    11-21-2018
    Location
    US
    MS-Off Ver
    2017
    Posts
    2

    Re: Macro Changing Text in a Cell Based on Text in Another

    Oops, sorry, I mean columns, not rows. More specifically, columns L and M.

    I've tried the second one, and while I'm not getting any errors when I run through it or use debugger, it's not making any of the updates.


    Sub GetText()

    Dim myCell As Variant
    Dim i As Long
    Dim myArray(1 To 3) As String

    myArray(1) = "New Application"
    myArray(2) = "Forwarded to Child Requisition"
    myArray(3) = "Pre-Offer"

    With Range("L2:L5000")

    For i = 1 To UBound(myArray)

    If .Value = myArray(i) Then
    Range("L1:L5000") = "New Applicants"
    ElseIf .Value = myArray(2) Then
    Range("L1:L5000") = "Interview"
    ElseIf .Value = "Pre-Offer" Then
    Range("L1:L5000") = "Offer"
    End If

    Next i

    End With

    With Range("M1:M5000")

    If .Value = "New Application" Then
    .Value = "New Applicants"
    End If

    End With

    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Help changing macro to function, selecting based on cell being text
    By kyles123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-16-2015, 12:12 PM
  2. Changing Text Box background based on other cell text
    By Zonc in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-15-2014, 04:45 AM
  3. Changing text based on another cell's number
    By Cori_W in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-16-2014, 11:16 AM
  4. Macro to automatically convert prt scr image-based text to real text in cell
    By jasonfromchico in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-24-2014, 02:27 PM
  5. Replies: 1
    Last Post: 02-19-2014, 10:04 PM
  6. changing text in one cell based on the value of another
    By jameseldridge in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-14-2013, 10:53 AM
  7. Changing text color of cell based on character
    By -Fate- in forum Excel General
    Replies: 8
    Last Post: 06-02-2010, 03:37 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