Results 1 to 8 of 8

Apply VBA code to multiple cells

Threaded View

  1. #1
    Registered User
    Join Date
    11-23-2013
    Location
    Oregon
    MS-Off Ver
    Excel Starter 2010
    Posts
    15

    Apply VBA code to multiple cells

    Hi there,

    I'm trying to make a drop-down menu within which multiple answers can be selected. I found some code online that I copy-pasted into my file and it works great, except that it only applies to one cell. I would like to have this multiple-selection enabled dropdown menu for a whole column of cells on my sheet.

    Here is the code:

    Private Sub Worksheet_Change(ByVal Target As Range)
    
        Dim oldVal As String
        Dim newVal As String
        
        If Target.Address(0, 0) <> "I4" Then Exit Sub
    
        On Error GoTo ReEnable
        Application.EnableEvents = False
        newVal = Target.Value
        Application.Undo
        oldVal = Target.Value
        Target.Value = newVal
    
        If oldVal <> "" And newVal <> "" Then
            Target.Value = oldVal & ", " & newVal
        End If
    ReEnable:
        Application.EnableEvents = True
        
    End Sub
    ...where I4 is just one of the cells in which I would want this kind of drop-down menu to appear. I have never used VBA before, so the answer may be obvious to others, but my question is: how can I apply this code to cells other than I4?

    Thanks!
    Last edited by alansidman; 10-06-2014 at 02:49 PM. Reason: code tags added

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Apply VBA code to multiple sheets
    By PaulusKabouter in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-26-2013, 11:37 AM
  2. Apply VBA code to multiple cells
    By jond291 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-31-2013, 07:33 AM
  3. [SOLVED] Can i modify this code to apply to multiple checkboxes and sheets?
    By stolen_83 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-14-2013, 02:44 PM
  4. [SOLVED] Match code to apply multiple cells in 1 Sub
    By colvinb in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-20-2012, 06:38 AM
  5. Need to apply VBA code to multiple Worksheets
    By parteegolfer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-12-2006, 04:43 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1