+ Reply to Thread
Results 1 to 18 of 18

Visual Basic - Not allowing cell entry

  1. #1
    Registered User
    Join Date
    07-08-2008
    Location
    Here
    Posts
    15

    Visual Basic - Not allowing cell entry

    Hello again,

    So I am still working on the same sheet and my question is as follows:

    I have a cell that I do no want anyone to enter any information into unless a previous cell has "U" inside of it. I know, I know confusing.

    Okay so so I have a column of cells named "Fringe Benefit Type" you can choose different letters to corropand to different types. Now I have set the letter "U" to be the one I want and that works. Now the next cell is called "Hire Season". Now (stay with me here) IF "Fringe Benefit Type" is equal to "U", I don't want the user to be able to enter anything into "Hire Season".

    I am using the visual basic thing, which already has some code, but I am not understanding it too well.
    Any help would be appreciated.
    Reply With Quote

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    How about posting the code, and explaining what happens that you don't like?

  3. #3
    Registered User
    Join Date
    07-08-2008
    Location
    Here
    Posts
    15
    Quote Originally Posted by shg View Post
    How about posting the code, and explaining what happens that you don't like?
    Thats the thing, I don't know much at all about the code, so I was hoping that someone could get me started...

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    What column is "Fringe Benefit Type" in? What column is "Hire Season"?

    You're aware that if you use code to modify a worksheet, the Undo stack is flushed, and that's OK?

  5. #5
    Registered User
    Join Date
    07-08-2008
    Location
    Here
    Posts
    15
    Quote Originally Posted by shg View Post
    What column is "Fringe Benefit Type" in? What column is "Hire Season"?

    You're aware that if you use code to modify a worksheet, the Undo stack is flushed, and that's OK?

    Fringe Benefit is Starts at cell P23 thru P62. Hire Season is R23-R62.

    That is fine,
    Thanks!

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Right-click on the sheet tab and paste this in the window that opens:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    07-08-2008
    Location
    Here
    Posts
    15
    Its not working, when I insert it into the field, it tells me "Ambugious name detected:Worksheet_Change"

    Your part is towards the end....
    This is how it looks:

    Please Login or Register  to view this content.
    Last edited by shg; 08-20-2008 at 05:56 PM. Reason: deleted spurious quote

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    1. I meant to say this before: Please quit quoting whole posts. It just clutters the forum.

    2. Please read the Forum Rules and then edit your post to wrap your code with Code Tags.

    3. You can only have one Worksheet_Change event.

  9. #9
    Registered User
    Join Date
    07-08-2008
    Location
    Here
    Posts
    15
    How do I change it so that it does not have a Worksheet_Change event?

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    2. Please read the Forum Rules and then edit your post to wrap your code with Code Tags.

    How do I change it so that it does not have a Worksheet_Change event?
    You have to merge the code in the two subs together so that the single event does everything you need done.

  11. #11
    Registered User
    Join Date
    07-08-2008
    Location
    Here
    Posts
    15
    Okay, done

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Thank you.

    Did you write the other worksheet change code?

  13. #13
    Registered User
    Join Date
    07-08-2008
    Location
    Here
    Posts
    15
    I honestly don't know how. I need to be walked thru this I think. So the code is appearing exactly like the following:
    Please Login or Register  to view this content.
    Please let me know exactly what I have to do to make it work. Thanks.

  14. #14
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Delete this, it's not doing anything:
    Please Login or Register  to view this content.
    Change all the Exit Sub statements to
    Please Login or Register  to view this content.
    Then add this line before my code:
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    07-08-2008
    Location
    Here
    Posts
    15
    This is what I have now:
    Please Login or Register  to view this content.
    Now its not doing anything.

  16. #16
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    You left off one of your End If statements. There should be (another) one above NextStep:
    Last edited by shg; 08-20-2008 at 07:04 PM.

  17. #17
    Registered User
    Join Date
    07-08-2008
    Location
    Here
    Posts
    15
    Okay this is what I have:
    Please Login or Register  to view this content.
    Now it is still giving me the Ambigious name detected: Worksheet_Change
    How would I change that?
    Thanks!

  18. #18
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Please Login or Register  to view this content.

+ 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. Dynamic Scrolling based on partial cell entry
    By carsto in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-10-2011, 05:48 PM
  2. Message box based on user entry in cell
    By hutch@edge.net in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-05-2008, 04:41 PM
  3. read cell content and use with Hyperlinks.Add Cell
    By apoc [t.i.m.] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-04-2007, 10:02 AM
  4. excel copy and paste visual basic
    By vakeeper in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-28-2007, 05:13 AM
  5. Changing text to Bold from another cell entry
    By TPD in forum Excel General
    Replies: 2
    Last Post: 09-19-2006, 02:31 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