Results 1 to 2 of 2

VBA - If a value matches a text string then

Threaded View

  1. #1
    Registered User
    Join Date
    01-01-2013
    Location
    Manchester, England
    MS-Off Ver
    Excel 2010 (work) & 2013 (home)
    Posts
    45

    VBA - If a value matches a text string then

    Hi Guys,

    I have another problem today:

    I've got a rather lengthy process at the moment to look in the cell that shows a shift in the format "8.30am - 4.30pm" and then the formula eventually tells you how many hours have been worked in the shift written.

    I've approached this with a mixture of LEFT, RIGHT, LEN, FIND, SEARCH and ABS to get the end result.

    I've started to write a UDF for this process but I'm stuck trying to get it to do the following. I've written this in VB but it doesn't work as intended:

    StartTimeTest = Val(Right(StartTimeStepOne, 3))
        
        If StartTimeTest = "pm" Then StartTimeStepFour = "YES" Else StartTimeStepFour = "NO"
    I'm not sure if you can use = for text strings; I guess not...

    Can anyone help?

    P.S. My VBA for this will probably be quite a lengthy bit of code as I'm a complete beginner - I would be looking to post my end result later on to see if anyone has any tips on improving etc.
    Last edited by elliotencore; 06-09-2013 at 02:53 PM.
    Elliot
    The geek shall inherit the earth

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