Skunk
Skunk

Reputation: 85

VBA, concact 2 values with the same variable in cell

I'm trying to write a VBA script. This script would read 1 column and write the result in another column.

If the values are in bold or if is not blank, I would like to write the data in the column b1.

But if the values are not in bold, I would like to write the data in c1, and concatenate if I have 2 or more non-bold data in the same cell.

My code :

Sub Phone()

Dim valueLogon As String
Dim ValueDevice As String
Dim compteur As Integer

compteur = 1

For i = 1 To 2101

    valueLogon = Range("A" & i)
    If Range("A" & i).Font.bold = True And IsEmpty(valueLogon) = False Then
        compteur = compteur + 1
        Range("C" & i) = valueLogon
    Else
        Range("D" & compteur) = valueLogon & "," &

    End If

Next i

End Sub

now, my result is like to the picture, but I would like concactenate the non-bold result in the same cell

enter image description here

Upvotes: 0

Views: 83

Answers (1)

SierraOscar
SierraOscar

Reputation: 17637

change

Range("D" & compteur) = valueLogon & "," &

to

Range("D" & compteur).Value = valueLogon & "," & Range("D" & comptuer).Value

Upvotes: 1

Related Questions