+ Reply to Thread
Results 1 to 5 of 5

Code to locate string or enter a new string with corresponding value

  1. #1
    Registered User
    Join Date
    04-07-2008
    Location
    Adelaide, SA
    Posts
    87

    Code to locate string or enter a new string with corresponding value

    Hi all,

    I am hoping someone can solve this problem I have.

    This is what i am trying to achieve:

    a) The user enters the track name into a userform and presses enter which activates the TrackPreferences Sub.

    b) The code then searches for the track name in column A, if it exists, it then enters the value "5" on the same row in the next column "B".

    c) If the track name doesn't exist, it then searches down column "A" until it finds the first empty cell and enters the new track name into it, along with the value "5" on the same row in the next column "B".

    Here is my code which doesn't work:

    Please Login or Register  to view this content.
    Thanks

    Yappa

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Yappa

    What in particular is not working? Is it the allocation of the textbox result to the variable? The sheet protect / unprotect??

    rylo

  3. #3
    Registered User
    Join Date
    04-07-2008
    Location
    Adelaide, SA
    Posts
    87
    The sheet protect and unprotect are not a concern.

    The problems lie within points b) and c) in my original post.

    Currently, if the user enters the track name and it exists in column "A" on the selected worksheet, the code executes. But, it puts the value on the current active row, column "B", not the newly selected row, column "B" from the finding like it should.

    I've also bypassed that section and executed the code so it goes straight to label Line3: . This should write the new track name in the first unused cell in column "A" but it doesn't, it throws an error.

    Also label Line3: should only execute if a match is not found.

    Here is my code again with some lines omitted from the first post that shouldn't have been there:

    Please Login or Register  to view this content.
    I hope this makes more sense.

    Yappa

  4. #4
    Registered User
    Join Date
    04-07-2008
    Location
    Adelaide, SA
    Posts
    87
    I've finally figured it out myself after a painstaking couple of days.

    Here is the working code if anyone is interested.

    Please Login or Register  to view this content.
    Yappa

  5. #5
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Yappa

    Have a look at the attached and see if that gives you some ideas.

    rylo
    Attached Files Attached Files

+ 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