Assign =concat( to a button?

donnabee

New Member
Joined
Jan 30, 2023
Messages
21
Office Version
  1. 365
Platform
  1. Windows
Hi there!
I'm essentially doing assessments in a workbook that has lines cut and pasted from a .csv
The csv is a list of photo names, coordinates etc.
I concat the photo names and then later all that information is fed into another workbook for upload - and the concat function tells that upload what photos to "take" from the folder.

The thing is, these sheets can be 10,000 lines plus so when identifying what photos I need, I end up typing =concat( hundreds of times.

I'd like to know if I can just have a button which would write the concat equation for me and I just go ahead and select the lines from there? So I select the cell where I'll be using the formula, press the button then hold control and click the cells containing the photos I need.

Please let me know if I haven't explained everything well enough.
 
You could also do something like this:

VBA Code:
activecell.formula = "=CONCAT(A1)"
application.Dialogs(xlDialogFunctionWizard).Show

then just replace the A1 reference with the cells you want in the dialog.
 
Upvote 0

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at:

There is no need to repeat the link(s) provided above but if you have posted the question at other places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
See if you could use this. I have placed a Forms button in A1 (but it could be anywhere) and attached the following macro to it.

View attachment 84213

VBA Code:
Sub ConcatNames()
  Dim rFormula As Range, rPics As Range
 
  Set rFormula = Intersect(Selection, Columns("B"))
  Set rPics = Intersect(Selection, Columns("A"))
  If rFormula Is Nothing Or rPics Is Nothing Then
    MsgBox "Error"
  Else
    rFormula.Formula = "=CONCAT(" & rPics.Address(0, 0) & ")"
  End If
End Sub

Now select all the cells in column A that you want concatenated and the cell in column B where you want the formula. It does not matter what order you do those things.
I selected all the green cells (cell B20 was empty when I selected it) and then pressed the button

donnabee.xlsm
AB
1Filename
2Pic1|
3Pic2|
4Pic3|
5Pic4|
6Pic5|
7Pic6|
8Pic7|
9Pic8|
10Pic9|
11Pic10|
12Pic11|
13Pic12|
14Pic13|
15Pic14|
16Pic15|
17Pic16|
18Pic17|
19Pic18|
20Pic19|Pic2|Pic4|Pic5|Pic9|Pic11|Pic12|Pic13|Pic14|Pic18|
21Pic20|
Sheet1
Cell Formulas
RangeFormula
B20B20=CONCAT(A3,A5:A6,A10,A12:A15,A19)
THANK YOU THANK YOU THANK YOU THANK YOU it works perfectly!!!

I can't thank you enough, this is amazing!!! Exactly what I needed!! Thank you!
 
Upvote 0
You are very welcome. Glad it worked well for you. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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