detriez
Board Regular
- Joined
- Sep 13, 2011
- Messages
- 193
- Office Version
- 365
- Platform
- Windows
I need to convert this to a formula
If a cell is not blank, concatenate the Header (nMerge1, nMerge2, nMerge3 etc) and the cell value
I use a named range for the header because the header will always change.
The challenge is, columns may be inserted or deleted which can change the column reference.. Would a named range be applicable here too?
Not every cell in the column will be populated so I cant use End(xlUP).Row
My formula.. Should this be AND or OR?
This should be the end result
If a cell is not blank, concatenate the Header (nMerge1, nMerge2, nMerge3 etc) and the cell value
I use a named range for the header because the header will always change.
The challenge is, columns may be inserted or deleted which can change the column reference.. Would a named range be applicable here too?
Not every cell in the column will be populated so I cant use End(xlUP).Row
VBA Code:
lr = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row + 1
Application.ScreenUpdating = False
With Range("AL2:AL" & lr)
.FormulaR1C1 = "=IF(RC[1]<>"""",CONCATENATE((R1C39&"": ""),RC[1])&CHAR(10),"""")&" & _
"IF(RC[2]<>"""",CONCATENATE((R1C40&"": ""),RC[2])&CHAR(10),"""")&" & _
"IF(RC[3]<>"""",CONCATENATE((R1C41&"": ""),RC[3])&CHAR(10),"""")&" & _
"IF(RC[4]<>"""",CONCATENATE((R1C42&"": ""),RC[4])&CHAR(10),"""")
My formula.. Should this be AND or OR?
Excel Formula:
=IF(AN2<>"",nMerge1&": "&AN2,"")&CHAR(10)
IF(AN2<>"",nMerge2&": "&Ap2,"")&CHAR(10)
IF(AN2<>"",nMerge3&": "&AP2,"")&CHAR(10)
IF(AN2<>"",nMerge4&": "&AQ2,"")&CHAR(10)
This should be the end result