Apply formula to Column AJ as long as column A is populated

detriez

Board Regular
Joined
Sep 13, 2011
Messages
193
Office Version
  1. 365
Platform
  1. 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

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
 
I think the Select statements were tripping me up.. I was trying to break down each step individually but kept getting confused
 
Upvote 0

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top