+ Reply to Thread
Results 1 to 6 of 6

If cell contains text then ......

  1. #1
    Registered User
    Join Date
    05-07-2006
    Location
    Brisbane Aus
    Posts
    6

    If cell contains text then ......

    Hi,

    Having a braindead morning here.

    I have 3 columns a=number, b=customer, c=quantity.

    Column B has various customer names.
    In column D, I need a formula which says if b2 contains text of any kind then show the text with (2) tagged on the end.
    ie if collins is showing in b2 then d2 should show Collins(2)

    Apologies for this, head all over

  2. #2
    Dave Peterson
    Guest

    Re: If cell contains text then ......

    =if(b2="","",b2&"(2)")

    Maybe????

    1ceman wrote:
    >
    > Hi,
    >
    > Having a braindead morning here.
    >
    > I have 3 columns a=number, b=customer, c=quantity.
    >
    > Column B has various customer names.
    > In column D, I need a formula which says if b2 contains text of any
    > kind then show the text with (2) tagged on the end.
    > ie if collins is showing in b2 then d2 should show Collins(2)
    >
    > Apologies for this, head all over
    >
    > --
    > 1ceman
    > ------------------------------------------------------------------------
    > 1ceman's Profile: http://www.excelforum.com/member.php...o&userid=34213
    > View this thread: http://www.excelforum.com/showthread...hreadid=540089


    --

    Dave Peterson

  3. #3
    CLR
    Guest

    Re: If cell contains text then ......

    =IF(ISTEXT(B2),B2&2,"")

    Vaya con Dios,
    Chuck, CABGx3


    "1ceman" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hi,
    >
    > Having a braindead morning here.
    >
    > I have 3 columns a=number, b=customer, c=quantity.
    >
    > Column B has various customer names.
    > In column D, I need a formula which says if b2 contains text of any
    > kind then show the text with (2) tagged on the end.
    > ie if collins is showing in b2 then d2 should show Collins(2)
    >
    > Apologies for this, head all over
    >
    >
    > --
    > 1ceman
    > ------------------------------------------------------------------------
    > 1ceman's Profile:

    http://www.excelforum.com/member.php...o&userid=34213
    > View this thread: http://www.excelforum.com/showthread...hreadid=540089
    >




  4. #4
    Registered User
    Join Date
    05-07-2006
    Location
    Brisbane Aus
    Posts
    6
    Ampersand !!!!!

    Thanks guys !!!!

  5. #5
    Registered User
    Join Date
    05-07-2006
    Location
    Brisbane Aus
    Posts
    6
    Guys, obviously, it works well.

    Thanks for that.

    Next Q......

    Can this be done in vba using xlformulas?

    Cheers

    Jeff

  6. #6
    Dave Peterson
    Guest

    Re: If cell contains text then ......

    Are you trying to update the values in place?

    Option Explicit
    Sub testme()
    Dim myRng As Range
    Dim myCell As Range

    With Worksheets("sheet1")
    Set myRng = .Range("b2", .Cells(.Rows.Count, "B").End(xlUp))
    End With

    For Each myCell In myRng.Cells
    If myCell.Value = "" Then
    'do nothing
    Else
    myCell.Value = myCell.Value & "(2)"
    End If
    Next myCell
    End Sub

    or if you wanted to update column C:

    Option Explicit
    Sub testme()
    Dim myRng As Range
    Dim myCell As Range

    With Worksheets("sheet1")
    Set myRng = .Range("b2", .Cells(.Rows.Count, "B").End(xlUp))
    End With

    For Each myCell In myRng.Cells
    If myCell.Value = "" Then
    'clear out the cell????
    mycell.offset(0,1).value = ""
    Else
    myCell.offset(0, 1).Value = myCell.Value & "(2)"
    End If
    Next myCell
    End Sub

    Be aware that the first routine will destroy any formulas in column B.


    1ceman wrote:
    >
    > Guys, obviously, it works well.
    >
    > Thanks for that.
    >
    > Next Q......
    >
    > Can this be done in vba using xlformulas?
    >
    > Cheers
    >
    > Jeff
    >
    > --
    > 1ceman
    > ------------------------------------------------------------------------
    > 1ceman's Profile: http://www.excelforum.com/member.php...o&userid=34213
    > View this thread: http://www.excelforum.com/showthread...hreadid=540089


    --

    Dave Peterson

+ 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