I am still very new with VBA and wouldn't put my hand up and say I'm good at this at all, 99% of everything I've made so far has been tossed together from other solutions found here (mostly) and elsewhere. I am trying to select a range, and then concatenate. Sounds simple enough and I've scoured a lot of posts talking about UDFs, using join/concat/transpose/etc.
Code I'm working with at the moment.
Sub ConcatThings()
Dim str() As String
Dim myRng As Range
Set myRng = Application.Selection
Set myRng = Application.InputBox("Select range of Stuff", "Select Stuff", "Maker of things", myRng.Address, Type:=8)
For Each myCell In myRng
If Len(myCell) Then
str = Join(myCell, ",")
ThisWorkbook.Sheets("general_report").Cells(2, 7) = str
End If
Next
End Sub
I'd like this to print the values to the general_report sheet in cell 2,7.
When I give it a go, I get a "Cant assign to array" and it highlights the str = Join
portion.
What am I doing wrong?
Update 1 - Here is a mockup of the sheet I am working with (all values were pulled out of the air)
_| A | B | C | D | E |
1|Jan | 2 | Grn| OSX|Bird|
2|Mar | 4 | Blu| PC |Frog|
3|Feb | 6 | Red| OSX|Dogs|
4|Nov | 0 | Wht| And|Cats|
5|Jun | 1 | Ylw| iOS|Worm|
When you run the macro, you would select whichever column is in question, and it would print the following in cell 2,7 Grn,Blu,Red,Wht,Ylw