You are here:

Excel/mac 2011 decreasing list VBA



I'm trying to write a VBA code for a validation list in excel 2011 for mac that removes an item in the list once it been selected so it cannot be selected in 2 cells at once. I'm new to VBA and I found a code online for this exact function but it wont work and I cant troubleshoot it. Can you tell me where my error is? This is the code I used:

Private Sub Worksheet_Change(ByVal Target As Range)

Dim strVal As String

Dim strEntry As String

   On Error Resume Next

       strVal = Target.Validation.Formula1

         If Not strVal = vbNullString Then

         strEntry = Target

         Application.EnableEvents = False

         With Sheet1.Range("Mylist")

         .Replace What:=strEntry, Replacement:="", _
         LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:=False

         .Sort Key1:=.Range("A1"), Order1:=xlAscending, Header:=xlNo, _
         OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

         .Range("A1", .Range("A65536").End(xlUp)).Name = "Mylist"

         End With

         End If

       Application.EnableEvents = True

   On Error GoTo 0

End Sub

I followed the directions( that accompanied the formula but nothing changed, the list works but the items don't disappear once selected.


Jeff -

The code works perfectly on my computer, so I'm pretty sure I know what the problem is. I have a PC. The VBA code has probably been written for the PC. You have a Mac - Mac Excel 2011 does not support scripting runtime objects, you have to create your own classes.

You can create your own Module and build your own classes. Unfortunately, although I understand the problem I can't help with the solution. If you don't know how to do build a Class file, that's OK - there are a number of examples and class library texts (too large to replicate here) that you can find.

Wish I could be more help - Andrea
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Andrea Lynch


I am very familiar with teaching excel concepts, and formulas. I am not as capable with VBA questions.


I currently tutor in this area. I worked for four years developing curriculum and teaching Microsoft applications to adult audiences. I also previously volunteered for

BA, English, Western Washington University Certificates in C Programming, ASP.NET, VisualBasic.NET, University of Washington Extension

Awards and Honors
Rated in the top ten instructors (national), New Horizons Computer Learning Center.

©2016 All rights reserved.