+ Reply to Thread
Results 1 to 5 of 5

Code refering to multiple cells

  1. #1
    Registered User
    Join Date
    12-04-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    8

    Code refering to multiple cells

    This thread had exactly what I needed to run the macro from a drop down list.

    http://www.excelforum.com/excel-prog...down-menu.html

    But I can not get it to work on multiple lists on the same sheet as it is locked to the one cell, any ideas or what changes to the code I need to make? I would need it to run on 4 dif cells.

    Thanks,

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Code refering to multiple cells

    Hi, wmaxwell,

    Dropdowns hold A, B and C as option, cells are B2, B4, C3, and C7 for the code to check, code goes behind the Worksheet:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    12-04-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Code refering to multiple cells

    Couldn't get this to work either.

    This is the code that I have in there now,

    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim Addx As String
    Dim Rng As Range

    Addx = Target.Validation.Formula1
    Set Rng = Range(Right(Addx, Len(Addx) - 1))

    If Target.Address = "$D$2" Then
    Select Case Target.Value
    Case Is = Rng.Cells(1, 1) 'First Drop Down Item
    Call SurfaceHole
    Case Is = Rng.Cells(2, 1) 'Second Drop Down Item
    Call FlocWater
    Case Is = Rng.Cells(3, 1) 'Third Drop Down Item
    Call PacPolymer
    End Select
    End If

    End Sub

    Works perfect on cell D2 but I need it to work on cells D28, D54, and D80.

    Thanks for the help.

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Code refering to multiple cells

    Hi, wmaxwell,

    did you try the code I suggested? The code you want to apply needs a list anywhere to rely on that for Data/Valdiation:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    12-04-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Code refering to multiple cells

    Hey Man, I did try the first one but couldn't get it to work.

    This last one work perfectly after I deleted this

    Sub SurfaceHole()
    MsgBox "SurfaceHole"
    End Sub

    Sub FlocWater()
    MsgBox "FlocWater"
    End Sub

    Sub PacPolymer()
    MsgBox "PacPolymer"
    End Sub

    Thanks!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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