+ Reply to Thread
Results 1 to 7 of 7

Macro in Validation List - Code Issues

  1. #1
    Registered User
    Join Date
    07-31-2013
    Location
    Gilbert, AZ
    MS-Off Ver
    Excel 2016
    Posts
    65

    Macro in Validation List - Code Issues

    I created a macro that refreshes a pivot table when a Validation List is changed....it works fine with the below code. I have a second tab that needs to have the same refresh pivot table macro function when another validation list is selected...I used the same code below but inserted the macro name for this refresh and nothing happens....do I need to make additional changes to the code for this to work on another tab?


    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim strMacro As String

    'Do nothing if more than one cell is changed or content deleted
    If Target.Cells.Count > 1 Then Exit Sub

    If Target.Address = "$G$3" Then
    strMacro = Target
    Run "RefreshPandL"

    End If

    If Target.Address = "$G$5" Then
    strMacro = Target
    Run "RefreshPandL"

    End If

    If Target.Address = "$G$7" Then
    strMacro = Target
    Run "RefreshPandL"
    End If

    End Sub

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Macro in Validation List - Code Issues

    the code must be in the code module for the sheet with the validation list-is it?

    you can simplify the code
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Registered User
    Join Date
    07-31-2013
    Location
    Gilbert, AZ
    MS-Off Ver
    Excel 2016
    Posts
    65

    Re: Macro in Validation List - Code Issues

    Yes it is....

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Macro in Validation List - Code Issues

    can you post the workbook? (I assume the ranges specified are correct?)

    also note I edited my post to simplify your code

  5. #5
    Registered User
    Join Date
    07-31-2013
    Location
    Gilbert, AZ
    MS-Off Ver
    Excel 2016
    Posts
    65

    Re: Macro in Validation List - Code Issues

    That worked perfectly...thanks for your help!

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Macro in Validation List - Code Issues

    you're welcome :-)

    please don't forget to mark the thread solved (click the 'thread tools' link at the top, then 'mark solved')

  7. #7
    Registered User
    Join Date
    07-31-2013
    Location
    Gilbert, AZ
    MS-Off Ver
    Excel 2016
    Posts
    65

    Re: Macro in Validation List - Code Issues

    Done...thx again

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Competition Template...No Spaces in Validation List needed.... manual calculation issues.
    By skyping in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-29-2013, 06:52 PM
  2. [SOLVED] Run code on any selection from validation list
    By lukestkd in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-30-2012, 10:54 AM
  3. Using VB code to create a validation list from another worksheet
    By parkhumi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-15-2012, 10:42 AM
  4. Need VBA code to use a data validation list
    By kattster in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-21-2012, 07:23 AM
  5. [SOLVED] Adding a validation list by code
    By Philippe Pons in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-01-2005, 12:05 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