+ Reply to Thread
Results 1 to 7 of 7

Macro changes my data validation list value

  1. #1
    Registered User
    Join Date
    09-30-2009
    Location
    Alexandria, VA
    MS-Off Ver
    Excel 2010
    Posts
    31

    Macro changes my data validation list value

    Whenever I run the following macro, it changes the current value of the data validation list ("YES" or "NO") to the opposite if it is "True." What can I do so that after it is done, I still have the same values. Thanks!!!

    If Sheets("Change Log").Range("B7") = "NO" Then
    Sheets("Change Log").Range("B5:B6").Copy
    Sheets("Change Log").Range("B16").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    End If
    Sheets("Change Log").Range("B7") = "YES"

    If Sheets("Change Log").Range("C7") = "NO" Then
    Sheets("Change Log").Range("C5:C6").Copy
    Sheets("Change Log").Range("B18").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    End If
    Sheets("Change Log").Range("C7") = "YES"
    Last edited by gophins; 09-30-2009 at 11:45 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: Macro changes my data validation list value

    hello gophins.

    Im not sure i completly understand. though if you ' or rem out both lines after the if statement.
    Please Login or Register  to view this content.
    range B7 and C7 will not change. though this will make the code copy the range's each time it is run.

    Hope this helps

  3. #3
    Registered User
    Join Date
    09-30-2009
    Location
    Alexandria, VA
    MS-Off Ver
    Excel 2010
    Posts
    31

    Re: Macro changes my data validation list value

    Thanks D_rennie,

    I'm kind of new to VBA...
    What do you mean by "if you ' or rem out both lines after the if statement."

    What I'm trying to do is copy certain ranges based on wheter the selection is YES or NO, but after those ranges have been copied there is more code that follows and depends on the same selections- the issue is that after the first pass, the Macro is "defaulting" to the opposite answer of the drop down list.

    Thank you

  4. #4
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: Macro changes my data validation list value

    By placing rem or ' before code
    the compiler will not prosess this.
    By using there you can place comments in your code for making things easer to read for other, or for when you long forget what it is the code is doing

    you have two if statements and after each of them you change the validation value.

  5. #5
    Registered User
    Join Date
    09-30-2009
    Location
    Alexandria, VA
    MS-Off Ver
    Excel 2010
    Posts
    31

    Re: Macro changes my data validation list value

    That did it! THANK YOU!!! D_Rennie

  6. #6
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: Macro changes my data validation list value

    You are welcome,
    Be sure to mark the thread as solved.
    Take a look at the forum rules to see how.

    Have a good day.

  7. #7
    Registered User
    Join Date
    09-30-2009
    Location
    Alexandria, VA
    MS-Off Ver
    Excel 2010
    Posts
    31

    Re: Macro changes my data validation list value

    The first post by D_Rennie was actually the solution - didn't figure it out right away. THANKS AGAIN!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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