i tried to write VBA code for below condtion which doesn't make any sense
code is for comparison - that is if C[1] is having the value same as C[3] then A[1] & A[3] values should be combined together with comma. for instance: consider that C[1] & C[3] having "split" then corresponding A[1] am & A[3] - "lright" should be combined and displayed in msg box as "am, alirgh". likewise code should do the same till the end of range.
below is my code which didn't work as expected
code is for comparison - that is if C[1] is having the value same as C[3] then A[1] & A[3] values should be combined together with comma. for instance: consider that C[1] & C[3] having "split" then corresponding A[1] am & A[3] - "lright" should be combined and displayed in msg box as "am, alirgh". likewise code should do the same till the end of range.
below is my code which didn't work as expected
Code:
Sub cal()
Dim i As Integer
Dim msg As String, str As String
'msg = ""
For i = 7 To 11
If ActiveSheet.Range("c" & i).Value = ActiveSheet.Range("c" & i + 1).Value Then
msg = ActiveSheet.Range("b" & i).Value
str = msg + msg
'msg = ""
End If
Next i
'MsgBox str, vbOKOnly
End Sub
Last edited: