VBA To Insert CONCAT For Two Table Fields

Raddle

New Member
Joined
Oct 24, 2023
Messages
41
Office Version
  1. 2016
Hi

Could anyone help out with where this is going wrong?

I need to insert the formula to concatenate two table fields. For some reason I am failing to do this using VBA, whilst I can do it directly in the cell.

With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=[@Question]&[@Answer]"

.. just can't seem to find the right combo of quotes / double quotes .. or am I just not in the right direction?

Any help v welcome and thank you
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Use a variable so you can inspect the concatenation first and see if what you are trying to assign to the Formula1 property makes sense.

VBA Code:
With Selection.Validation
.Delete

Dim FormulaStr As String

FormulaStr = "=[@Question]&[@Answer]"
Debug.Print FormulaStr

.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=FormulaStr


(Tip: For future posts , please try to use code tags like I did above when posting code. It makes your code easier to read and copy.
)
 
Upvote 0
Solution
What a star you are .. that helped me realise that I didn't want validation at all ... I just wanted to put the concat formula in .

Thank you so much :)

Have a great weekend
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,212
Members
452,618
Latest member
Tam84

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