+ Reply to Thread
Results 1 to 4 of 4

Concatenate Non Blank Cells

  1. #1
    ssjody
    Guest

    Concatenate Non Blank Cells

    Hi,

    On Sheet1 I want to be able to enter a Value in Column A and another
    Value in Column B and have them concatenate in Column C with a } in
    between them. I only want this to happen when Column A is Not Blank. If
    only Column A has a Value then the result would be ColumnAValue}

    I know I can do this with :
    =IF(A1="","",CONCATENATE(A1,"}",B1))
    but I really want to be able to do this with VBA code instead of a
    formula. How do I do this?

    Thanks Jody


  2. #2
    Soniya
    Guest

    Re: Concatenate Non Blank Cells

    Range("C1").FormulaR1C1 = _
    "=IF(RC1="""","""",CONCATENATE(RC1,""}"",RC2))"


  3. #3
    evgny
    Guest

    Re: Concatenate Non Blank Cells


    Soniya wrote:
    > Range("C1").FormulaR1C1 = _
    > "=IF(RC1="""","""",CONCATENATE(RC1,""}"",RC2))"



    hi ssjody

    try this

    Sub a()
    Worksheets("Ark1").Activate
    Dim colA As Double ' CHECK HOW MANNY ROWS IN COLUMNS A
    Dim colB As Double ' CHECK HOW MANNY ROWS IN COLUMNS B
    Dim Big As Double
    Dim i As Double
    colA = Cells(Rows.Count, "B").End(xlUp).Row
    colB = Cells(Rows.Count, "B").End(xlUp).Row
    If colA > colB Then
    Big = colA
    Else
    Big = colB
    End If
    For i = 1 To Big
    If Range("A" & i) > 0 Then

    Range("C" & i) = Range("A" & i) & Range("B" & i)
    End If
    Next i
    End Sub

    Regards yngve


  4. #4
    ssjody
    Guest

    Re: Concatenate Non Blank Cells

    Thanks yngve! That's exactly what I wanted.

    Jody


+ 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