VBA - Textjoin for the whole column

Shukis7

New Member
Joined
Dec 14, 2021
Messages
22
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm trying to use the Textjoin function in VBA.

I know how to do it for the first row, but I'm having issues when I want it to apply for the whole column.

For example, I want it to start at AH2 and the formula on the cell should be =TEXTJOIN("-",TRUE,I2,AE2,AF2,AG2).
For AH3 the formula should be =TEXTJOIN("-",TRUE,I3,AE3,AF3,AG3) and the same for AH4...
I know it should be something for i =1 in the range ... but I can't figure it out. (for each cell in range)

Any help would be really appreciated.

Thanks!
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
There's a number of ways you could do this, here's just one:

VBA Code:
Sub Shukis7()
    Dim lr As Long
    lr = Cells.Find("*", , xlFormulas, , 1, 2).Row
    With Range("AH2:AH" & lr)
        .FormulaR1C1 = "=TEXTJOIN("" - "",TRUE,RC9,RC31,RC32,RC33)"
        .Value2 = .Value2
    End With
End Sub
 
Upvote 0
Solution
Wow, thank you so much! I'm still new to this and trying to learn. I really appreciate your help.
 
Upvote 0
I have a similar issue with my next task, but this time instead of textjoin the formula is: =IF(COUNTIF($AH$2:AH2,AH2)>1,"Duplicate","Original")
The concept is the same, but now I am using only the column AH (RC34). I've tried modifying the previous formula, but it doesn't seem to work. I can start a new thread if you prefer. Thanks again!
 
Upvote 0
Best to start a new thread, though due to time zone differences, it'll be some time before I get to it. You'll probably get assistance from others on the forum though.
 
Upvote 0

Forum statistics

Threads
1,215,388
Messages
6,124,659
Members
449,178
Latest member
Emilou

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