detriez
Board Regular
- Joined
- Sep 13, 2011
- Messages
- 193
- Office Version
- 365
- Platform
- Windows
I am trying to apply this formula to column AJ where column A is populated
My sheet has headers and this formula will result in some blank AJ cells. Column A is always populated
This code places the formula into the selected cell rather than column AJ
My sheet has headers and this formula will result in some blank AJ cells. Column A is always populated
Code:
=IF(AK2<>"",CONCATENATE(($AK$1&": "),AK2)&CHAR(10),"")&IF(AL2<>"",CONCATENATE(($AL$1&": "),AL2)&CHAR(10),"")&IF(AM2<>"",CONCATENATE(($AM$1&": "),AM2)&CHAR(10),"")&IF(AN2<>"",CONCATENATE(($AN$1&": "),AN2)&CHAR(10),"")&IF(AO2<>"",CONCATENATE(($AO$1&": "),AO2)&CHAR(10),"")&IF(AP2<>"",CONCATENATE(($AP$1&": "),AP2)&CHAR(10),"")&IF(AQ2<>"",CONCATENATE(($AQ$1&": "),AQ2)&CHAR(10),"")&IF(AR2<>"",CONCATENATE(($AR$1&": "),AR2)&CHAR(10),"")&IF(AS2<>"",CONCATENATE(($AS$1&": "),AS2)&CHAR(10),"")&IF(AT2<>"",CONCATENATE(($AT$1&": "),AT2),"")
This code places the formula into the selected cell rather than column AJ
Code:
Dim lr As Longlr = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
Application.ScreenUpdating = False
With ActiveSheet
ActiveCell.FormulaR1C1 = _
"=IF(RC[1]<>"""",CONCATENATE((R1C37&"": ""),RC[1])&CHAR(10),"""")&IF(RC[2]<>"""",CONCATENATE((R1C38&"": ""),RC[2])&CHAR(10),"""")&IF(RC[3]<>"""",CONCATENATE((R1C39&"": ""),RC[3])&CHAR(10),"""")&IF(RC[4]<>"""",CONCATENATE((R1C40&"": ""),RC[4])&CHAR(10),"""")&IF(RC[5]<>"""",CONCATENATE((R1C41&"": ""),RC[5])&CHAR(10),"""")&IF(RC[6]<>"""",CONCATENATE((R1C42&"": ""),RC[6]" & _
")&CHAR(10),"""")&IF(RC[7]<>"""",CONCATENATE((R1C43&"": ""),RC[7])&CHAR(10),"""")&IF(RC[8]<>"""",CONCATENATE((R1C44&"": ""),RC[8])&CHAR(10),"""")&IF(RC[9]<>"""",CONCATENATE((R1C45&"": ""),RC[9])&CHAR(10),"""")&IF(RC[10]<>"""",CONCATENATE((R1C46&"": ""),RC[10]),"""")" & _
""
End With
Application.ScreenUpdating = True