+ Reply to Thread
Results 1 to 4 of 4

Filling in text to the left and right of a cell

  1. #1
    Registered User
    Join Date
    06-10-2007
    Posts
    2

    Question Filling in text to the left and right of a cell

    Hiya

    Ok so im a noob when it coes to programming in excel, ive done vb.net stuff in the past, but im kind of stuck here!

    Ive got 6 boxes, and im trying to make it so when a user enters info into a box the box to the left and box to the right get filled in with the text "unavailable"

    I can get it to work one way or the other but not both! Excel just crashes!!

    Here is the code im using:

    Please Login or Register  to view this content.
    Is there a better way to do this?

    Any help would be great!

    Thanks

    Bob

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    How about using just simple formulas?

    e.g. =If(A1<>"","unavailable","")

    Where A1 is first of those 6 cells. Just adjust to match your cell position and copy down.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Bob,

    Excel crashes due to an event cascade failure. You are using the Worksheet_Change event to capture when a cell is changed. When you change a cell in the event, the event calls it self again, and round round we go until there is no stack space left.

    Fortunately, you can stop the madness. "Application.EnableEvents" controls the triggering of Excel's events. Always disable the events before you change a cell in the Worksheet_Change event, and re-enable the events before exiting the Sub.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  4. #4
    Registered User
    Join Date
    06-10-2007
    Posts
    2

    Lightbulb

    Hiya

    Thanks for the replyies!!

    Ive got it working perfectly now!

    Just a note to the first post, the reason i can use formula is that i want people to type in the boxes, so a forumula would be deleted.

    But the second alteration to my code is just the job!

    Many many thanks

    Bob

+ 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