+ Reply to Thread
Results 1 to 5 of 5

cell value as text string?

  1. #1
    Registered User
    Join Date
    07-28-2015
    Location
    Boston, MA
    MS-Off Ver
    MS Office 2010
    Posts
    8

    cell value as text string?

    Hi - I have the following code that I need to run on many different reports. For each report, the text string will be different. (For this one it's "COHEN" but for another one it might be "SMITH" or "JONES", etc.

    Is there a way to make the text string = value from a cell, or maybe an input box, so i don't have to open VB editor and change the name every time?

    Columns("F:F").Select
    Selection.FormatConditions.Add Type:=xlTextString, String:="COHEN", _
    TextOperator:=xlContains
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Font
    .Color = -16383844
    .TintAndShade = 0
    End With
    With Selection.FormatConditions(1).Interior
    .PatternColorIndex = xlAutomatic
    .Color = 13551615
    .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    Cells.Select
    ActiveWorkbook.Worksheets("Main").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Main").Sort.SortFields.Add(Range("F2"), _
    xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = RGB(255, _
    199, 206)
    ActiveWorkbook.Worksheets("Main").Sort.SortFields.Add Key:=Range("B2"), _
    SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Main").Sort
    .SetRange Range("A1:M9999")
    .Header = xlYes
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
    .Apply
    End With

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: cell value as text string?

    Perhaps, if the name is in A2.
    Please Login or Register  to view this content.
    PS Can you add code tags when posting code?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    07-28-2015
    Location
    Boston, MA
    MS-Off Ver
    MS Office 2010
    Posts
    8

    Re: cell value as text string?

    Thanks, I was actually able to figure out the issue, but now i'm stuck on this one:

    Please Login or Register  to view this content.

    the name for each report will be populating in cell N4. Is it possible to search whatever text is in N4 instead of changing the text string over and over?

  4. #4
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: cell value as text string?

    If you want N4 in your formula instead of James Cohen, then try this:
    Please Login or Register  to view this content.
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  5. #5
    Registered User
    Join Date
    07-28-2015
    Location
    Boston, MA
    MS-Off Ver
    MS Office 2010
    Posts
    8

    Re: cell value as text string?

    nope, unfortunately that just returns all "Ecard" in the destination cells

+ 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. [SOLVED] Search for a text string and return given text string to adjacent cell
    By hecgroups in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-14-2015, 04:50 AM
  2. [SOLVED] Copy any bold text within a cell text string to an adjacent cell
    By Groovicles in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-31-2014, 06:22 PM
  3. [SOLVED] IF range of cells contains string of text, return contents of cell where string is found
    By nobodyukno in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-03-2013, 09:56 AM
  4. [SOLVED] Find partial text string within another text string return original text into cell.
    By mikey42979 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-17-2013, 02:58 PM
  5. Replies: 8
    Last Post: 08-07-2012, 10:15 AM
  6. Replies: 9
    Last Post: 10-17-2011, 04: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