VBA Data validation with Indirect and Vlookup

reganhayward

New Member
Joined
Jun 29, 2012
Messages
2
Hi There

I'm an average user of Excel and VBA and have come become stuck with some code I'm trying to get working.

I have a insert rows button that inserts a new row, this includes adding in some data validation among other things.

This is fine until I try to make my formula dynamic. This part works

With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=INDIRECT(VLOOKUP($I$35,NameLookup,2,0))"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = "External colour"
.ErrorTitle = ""
.InputMessage = "Select the external colour you require"
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With

When I try to update $I$35 in the Vlookup with a dynamic location a few columns before, the code doesn't work

' With Selection.Validation
' .Delete
' .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
' xlBetween, FormulaR1C1:="=INDIRECT(VLOOKUP(rc9,NameLookup,2,0))"
' .IgnoreBlank = True
' .InCellDropdown = True
' .InputTitle = "External colour"
' .ErrorTitle = ""
' .InputMessage = "Select the external colour you require"
' .ErrorMessage = ""
' .ShowInput = True
' .ShowError = True
' End With


Hopefully this is just a user error and is easy to fix!

Thanks!!
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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