+ Reply to Thread
Results 1 to 19 of 19

can not get vb 2 run, testing cell string match, then trying 2 write new value in new cell

  1. #1
    Registered User
    Join Date
    07-28-2012
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    31

    can not get vb 2 run, testing cell string match, then trying 2 write new value in new cell

    I have written some VB to check an entry from a drop down list. the first sub converts lowercase to uppercase (this is working), then I wish to check string from dropdown to hard coded strings, and if match, write a single hard coded character to new cell on same page, and write another hard coded value to another cell. The case conversion works fine, but not the next sub to check strings... once that works I think I know how to write hardcoded characters to cells...

    Please Login or Register  to view this content.
    Last edited by Leith Ross; 07-28-2012 at 06:41 PM. Reason: Added Code Tags

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

    Re: can not get vb 2 run, testing cell string match, then trying 2 write new value in new

    Hello regupnorth,

    Welcome to the Forum!

    What results are you are getting from the macros when they execute?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    07-28-2012
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    31

    Re: can not get vb 2 run, testing cell string match, then trying 2 write new value in new

    No response at all, its as if it never ran. I previously had imbedded some MsgBox in the If statements to get a feel which way it solved, but they do not show up either.
    The case conversion works when I enter lower case into the cell in the next column, so I know the first sub runs fine. Thank you for your reply...

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,540

    Re: can not get vb 2 run, testing cell string match, then trying 2 write new value in new

    Maybe:

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,540

    Re: can not get vb 2 run, testing cell string match, then trying 2 write new value in new

    If nothing happens, it sounds as though your event handling has been switched off.

    Regards, TMS

  6. #6
    Registered User
    Join Date
    07-28-2012
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    31

    Re: can not get vb 2 run, testing cell string match, then trying 2 write new value in new

    Quote Originally Posted by TMShucks View Post
    Maybe:

    Please Login or Register  to view this content.

    Regards, TMS
    Just put in "Application.EnableEvents = True" right before first If, still nothing...

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,540

    Re: can not get vb 2 run, testing cell string match, then trying 2 write new value in new

    Well, it won't ... it's an event handler

    Type that command into the immediate window and press enter.

    The try.

  8. #8
    Registered User
    Join Date
    07-28-2012
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    31

    Re: can not get vb 2 run, testing cell string match, then trying 2 write new value in new

    Forgive my lack of knowledge, but what is "immediate window"?

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,540

    Re: can not get vb 2 run, testing cell string match, then trying 2 write new value in new

    In the VBE, press Ctrl-G. You should get a little window under the code pane. Type in there. Or you can press View on the menu.

  10. #10
    Registered User
    Join Date
    07-28-2012
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    31

    Re: can not get vb 2 run, testing cell string match, then trying 2 write new value in new

    Did that, nothing happened. Went back to spreadsheet, chose from drop down list, nothing happened. Then next cell, typed in lowercase string, hit enter, it changed to uppercase.

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

    Re: can not get vb 2 run, testing cell string match, then trying 2 write new value in new

    Hello regupnorth,

    Did you enable VBA macros in the Trust Center?

    How to Change macro security settings in Excel 2010

  12. #12
    Registered User
    Join Date
    07-28-2012
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    31

    Re: can not get vb 2 run, testing cell string match, then trying 2 write new value in new

    Have done that.
    Also, first sub runs OK.
    Still nothing to show second one is even running...
    Last edited by Cutter; 07-30-2012 at 08:14 AM. Reason: Removed whole post quote

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

    Re: can not get vb 2 run, testing cell string match, then trying 2 write new value in new

    Hello regupnorth,

    If your worksheet is not protected then you should post your workbook for review.

  14. #14
    Registered User
    Join Date
    07-28-2012
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    31

    Re: can not get vb 2 run, testing cell string match, then trying 2 write new value in new

    How do I do that? Just paste it into here?
    Last edited by Cutter; 07-30-2012 at 08:15 AM. Reason: Removed whole post quote

  15. #15
    Registered User
    Join Date
    07-28-2012
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    31

    Re: can not get vb 2 run, testing cell string match, then trying 2 write new value in new

    Oops. I see the attachment section now... Here you go.
    Attached Files Attached Files

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

    Re: can not get vb 2 run, testing cell string match, then trying 2 write new value in new

    Hello regupnorth,

    The code in the workbook runs. It probably is not running the way you intended it to. When the user selects "Battery" from the validation drop down, this triggers the Worksheet_Change event. The code you have in this event converts the entry in cell "B" to uppercase. This works as you said.

    The second part of what you want, to copy the cell contents from cell "B" to "C", is controlled by the Worksheet_SelectionChange event. This event is fired only when the cursor is moved to another cell and the users clicks that cell to select it. Select "Battery" in cell B14. Click cell B15 and then go back and click B14. It will copy over to C14.

  17. #17
    Registered User
    Join Date
    07-28-2012
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    31

    Re: can not get vb 2 run, testing cell string match, then trying 2 write new value in new

    Thats interesting...
    What I want is for the user to select from the dropdown, then I want the user's cursor placed in the next cell to enter the serial number. The serial numbers must be in uppercase, thus the case conversion. When the user is placed in the next cell, I want to place some leading characters in that cell to ensure they conform to the standard serial number format. For Battery, it would move to the next cell, and place a capital B in that cell, with the user cursor awaiting the next alpha numeric entry to complete it. Then the upper case conversion ensures it is all caps. In addition, I will be drawing from a list on the lists page, the item's weight, based on the "Battery" selection,and placing that value automatically into the weight column corresponding to the row entry. Any suggestions? Thank you.

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

    Re: can not get vb 2 run, testing cell string match, then trying 2 write new value in new

    Hello regupnorth,

    I think it would be easier to do this using a UserForm to control the data entry the way you want and then transfer it to the worksheet. With the UserForm you could make use of the ActiveX ComboBox which will automatically match an entry in the list as you type.

  19. #19
    Registered User
    Join Date
    07-28-2012
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    31

    Re: can not get vb 2 run, testing cell string match, then trying 2 write new value in new

    Thanx. I did just that. Now I am back to where, based on the item selected in the combobox, I want to test it, I assume with an IF, and based on the match, I want to populate a text box as the focus goes to that textbox, with a character hard coded in the THEN, followed by an OR IF, and so on.... Where would I put this code?
    Last edited by Cutter; 07-30-2012 at 08:15 AM. Reason: Removed whole post quote

+ 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