1
votes

I am using vba to get combined value in an cell from selection range

what i wanna do is.. i give selection in sheet and run my vba code then in result i would get merged value in an another cell.

but instead of this i am getting value "TRUE"

** in my code i replace enter to comma & for enter i used chr(10).

code i am using is:

Sub abc()
Dim a As String
Dim b As String
a = Selection.Copy
b = Replace(a, Chr(10), ",")
ActiveCell.Offset(4, 0).Value = b
ActiveCell.Offset(4, 1).Value = a
End Sub

image

1

1 Answers

2
votes

Try this:

Sub abc()
    Dim a As String
    Dim b As String
    a = ActiveCell.Value
    b = Replace(a, Chr(10), ",")
    ActiveCell.Offset(4, 0).Value = b
    ActiveCell.Offset(4, 1).Value = a
End Sub