Hello,
I am confused about str1 being cell B2 and user input. That would equate to the cell being both str1 and str2.
I see that in the comments of the code columns B:B and D:D are populated from VBA and that column C:C is user input.
Below is some VBA that may get closer to your goal. Test it out on a copy to see how it does:
In the worksheet module. Right click the sheet tab and choose Veiw Code:
<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Worksheet_Change(<SPAN style="color:#00007F">ByVal</SPAN> Target <SPAN style="color:#00007F">As</SPAN> Range)<br><SPAN style="color:#007F00">'Application.EnableEvents = False</SPAN><br><br><SPAN style="color:#00007F">Dim</SPAN> Changed <SPAN style="color:#00007F">As</SPAN> Range<br><SPAN style="color:#00007F">Dim</SPAN> Ws <SPAN style="color:#00007F">As</SPAN> Worksheet<br> <br><SPAN style="color:#00007F">Set</SPAN> Ws = ActiveSheet<br><SPAN style="color:#00007F">Set</SPAN> Changed = Intersect(Target, Ws.Range("C2:C" & Range("D" & Rows.Count).End(xlUp).Row))<br><br><SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">Resume</SPAN> <SPAN style="color:#00007F">Next</SPAN><br> <SPAN style="color:#00007F">If</SPAN> Target.Offset(0, -2).Value = "" <SPAN style="color:#00007F">Or</SPAN> Len(Target.Offset(0, -2).Value) _<br> - Len(Replace(Target.Offset(0, -2).Value, " ", "")) <> 1 <SPAN style="color:#00007F">Then</SPAN><br> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br> <SPAN style="color:#00007F">Else</SPAN><br> <SPAN style="color:#00007F">If</SPAN> <SPAN style="color:#00007F">Not</SPAN> Changed <SPAN style="color:#00007F">Is</SPAN> <SPAN style="color:#00007F">Nothing</SPAN> <SPAN style="color:#00007F">Then</SPAN><br> <br> Target.Offset(0, -2).Value = Replace(Target.Offset(0, -2).Value, " ", Target.Value)<br> <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br> <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br><SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">GoTo</SPAN> 0<br><SPAN style="color:#007F00">'Application.EnableEvents = True</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
Then in a standard module:
<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> JoinStrLooped()<br>Application.EnableEvents = <SPAN style="color:#00007F">False</SPAN><br><br><SPAN style="color:#00007F">Dim</SPAN> str1 <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, str2 <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, str3 <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, strTotal <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN><br><SPAN style="color:#00007F">Dim</SPAN> c <SPAN style="color:#00007F">As</SPAN> Range, cRng <SPAN style="color:#00007F">As</SPAN> Range<br><SPAN style="color:#00007F">Dim</SPAN> Ws <SPAN style="color:#00007F">As</SPAN> Worksheet<br><br><SPAN style="color:#00007F">Set</SPAN> Ws = Sheets("Sheet1")<br><SPAN style="color:#00007F">Set</SPAN> cRng = Ws.Range("D2:D" & Range("D" & Rows.Count).End(xlUp).Row)<br> <br> <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> c <SPAN style="color:#00007F">In</SPAN> cRng<br> str1 = Ws.Range("B" & c.Row).Value<br> <SPAN style="color:#00007F">If</SPAN> Ws.Range("C" & c.Row) <> "" <SPAN style="color:#00007F">Then</SPAN><br> str2 = Ws.Range("C" & c.Row).Value<br> <SPAN style="color:#00007F">Else</SPAN><br> str2 = " "<br> <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br> str3 = Ws.Range("D" & c.Row).Value<br> strTotal = str1 & str2 & str3<br> Ws.Range("A" & c.Row) = strTotal<br> <SPAN style="color:#00007F">Next</SPAN> c<br>Application.EnableEvents = <SPAN style="color:#00007F">True</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>