+ Reply to Thread
Results 1 to 6 of 6

Help with a worksheet control to govern column data entry ...

  1. #1
    Registered User
    Join Date
    01-17-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    23

    Question Help with a worksheet control to govern column data entry ...

    Hi all - new to VBA and trying to get this to work - any assistance is grateful.

    I am looking to control data entry in one of two worksheet columns (14 and 16) -such that data entry will only be accepted in one column OR the other, but not both.

    Ideally, the code should behave such that once text (from a drop down list) is selected in one column (14 or 16), nothing occurs (e.g.this is acceptable), however, once text is selected in BOTH columns (14 AND 16), the other cell is deleted and a message box is thrown indicating that one or the other can contain text, but not both.

    Here is what I have so far:

    Please Login or Register  to view this content.
    However, this does not seem to work. Any ideas?

  2. #2
    Registered User
    Join Date
    04-02-2012
    Location
    NY
    MS-Off Ver
    Excel 2003 / 2007
    Posts
    7

    Re: Help with a worksheet control to govern column data entry ...

    I believe the issue is with this line of code - Target.ClearContents

    If you're using Validation Drop-Down Lists (Which I believe you are), then maybe that is why that line of code is failing. It seems that trying to clear the actual cell isn't working, so maybe undoing the last change made to the drop-down list will. You can do that using the following code - Application.Undo

    I'm new to VBA, so I'm not sure this is accurate.

    I hope that solves your problem.

    Wes
    Last edited by OmegaWes2012; 01-22-2013 at 04:20 PM.

  3. #3
    Registered User
    Join Date
    01-17-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Help with a worksheet control to govern column data entry ...

    Please Login or Register  to view this content.
    Ok I tried the above and still doesn't seem to work - I am wondering if a boolean is not the best approach for this?

    Many thanks again!

  4. #4
    Registered User
    Join Date
    04-02-2012
    Location
    NY
    MS-Off Ver
    Excel 2003 / 2007
    Posts
    7

    Red face Re: Help with a worksheet control to govern column data entry ...

    NikonMan - My apologies, I wasn't able to test the code you provided before, but I did test the block of code below. As I am fairly new to VBA, I would assume one of the moderators might be able to provide a better, more efficient solution.

    Please Login or Register  to view this content.
    This worked for me when I tested it. I've also attached the test file I used.

    Hope this helps.

    Wes
    Attached Files Attached Files
    Last edited by OmegaWes2012; 01-22-2013 at 04:17 PM.

  5. #5
    Registered User
    Join Date
    01-17-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Help with a worksheet control to govern column data entry ...

    Ok thanks Wes - I will give your code a shot and report back - somehow mine is not functional as is ...

    Cheers
    -Steve

  6. #6
    Registered User
    Join Date
    01-17-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Help with a worksheet control to govern column data entry ...

    Quote Originally Posted by OmegaWes2012 View Post
    NikonMan - My apologies, I wasn't able to test the code you provided before, but I did test the block of code below. As I am fairly new to VBA, I would assume one of the moderators might be able to provide a better, more efficient solution.

    Please Login or Register  to view this content.
    This worked for me when I tested it. I've also attached the test file I used.

    Hope this helps.

    Wes
    This code works great - thanks so much!

+ 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