Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Excel VBA UserInterFaceOnly problems when adding listbox

Avatar of mcs26
mcs26 asked on
Microsoft AccessVisual Basic ClassicMicrosoft Excel
4 Comments1 Solution788 ViewsLast Modified:

I have a worksheet that is password protected so I found that I could use the UserInterFaceOnly property to allow my VBA code to make changes to my sheet whilst keeping the sheet protected.

This works up till a point, I can make changes through my code but it bugs out at one point below. The line .Add xlValidateList ..... is where the bug appears. The error message is Method ‘Add’ of object ‘Validation’ failed. Now when I unprotect the sheet and take out the UserInterFaceOnly property the same code below works perfectly!

Set RngListBox = Range("C" & i)
        With RngListBox.Validation
            .Add xlValidateList, xlValidAlertInformation, xlBetween, ListWeight
            .InCellDropdown = True
        End With

Any help would be great, thanks