Hi
I have a spreadsheet with individual headings, and cell data in those columns that can either be 1, 2 or 3. I need to add a column that, for example, looks at each cell in row 2 and concatenates the column heading for each cell which has a value of 2. This would then give me a list in the first cell in row 2 of all the columns meeting that criteria.
An example would be:
Names / Result column / module a / module b / module c
Tom / module b / 1 / 2 / 3
Dick / module a; module b /2 / 2 / 3
Harry / / 1 / / 1
I'm sorry if the layout isn't totally clear, but I can't get the tabs to stay in place after I click the next button.
I can do a basic concatenate by using =concatenate(=if(b1=1,a1&2", ",null,etc but this only works until the limit on the number of characters in the formula is reached.
I have found code on the internet which concatenates ranges. However, I can't find a way to select only certain values from that range, or to show the column headings instead of the value of the cells themselves.
The code I have found is:
Function concatenaterangemedium(Parts As Range, Separator As String)
Dim strTemp, sepTemp As String
Dim cel As Range
Dim toprow As Range
Dim cnt As Integer
strTemp = ""
For Each cel In Parts.Cells
If cel.Value = "" Or cel.Value = 0 Then
sepTemp = ""
Else
sepTemp = Separator
End If
strTemp = strTemp & sepTemp & cel.Value
Next cel
concatenaterangemedium = strTemp
End Function
What it does is concatenate a range of cell data in a row, and puts separators between each cell value.
What I would like it to do is only concatenate the cell values if they are a certain value. For example, only concatenate for cells with the value of 2. When I have tried amending the code I've ended up with all the values in, but the separator missed out after the value 2, which is totally wrong.
Thank you.
I have a spreadsheet with individual headings, and cell data in those columns that can either be 1, 2 or 3. I need to add a column that, for example, looks at each cell in row 2 and concatenates the column heading for each cell which has a value of 2. This would then give me a list in the first cell in row 2 of all the columns meeting that criteria.
An example would be:
Names / Result column / module a / module b / module c
Tom / module b / 1 / 2 / 3
Dick / module a; module b /2 / 2 / 3
Harry / / 1 / / 1
I'm sorry if the layout isn't totally clear, but I can't get the tabs to stay in place after I click the next button.
I can do a basic concatenate by using =concatenate(=if(b1=1,a1&2", ",null,etc but this only works until the limit on the number of characters in the formula is reached.
I have found code on the internet which concatenates ranges. However, I can't find a way to select only certain values from that range, or to show the column headings instead of the value of the cells themselves.
The code I have found is:
Function concatenaterangemedium(Parts As Range, Separator As String)
Dim strTemp, sepTemp As String
Dim cel As Range
Dim toprow As Range
Dim cnt As Integer
strTemp = ""
For Each cel In Parts.Cells
If cel.Value = "" Or cel.Value = 0 Then
sepTemp = ""
Else
sepTemp = Separator
End If
strTemp = strTemp & sepTemp & cel.Value
Next cel
concatenaterangemedium = strTemp
End Function
What it does is concatenate a range of cell data in a row, and puts separators between each cell value.
What I would like it to do is only concatenate the cell values if they are a certain value. For example, only concatenate for cells with the value of 2. When I have tried amending the code I've ended up with all the values in, but the separator missed out after the value 2, which is totally wrong.
Thank you.