+ Reply to Thread
Results 1 to 3 of 3

help with StrReverse function

  1. #1
    RompStar
    Guest

    help with StrReverse function

    Ok, I have this script that looks in two columns on the same row, and
    if the date and name matches, it changes the HR code in the third
    column.

    It works great and even got the lowercase to work, so it don't matter
    how it's entered, but I still would like to make it better and not sure
    if I should use the right function ? StrReverse ?

    But bascially I wanted it to work in a way so that if

    Someone enters in search

    Jim Smith
    or
    Smith Jim

    it wouldn't matter I have the case not matter, which is good, but
    would like to also make the order not matter, I get a error 13 when I
    try to use it, not sure, any help would be appreciated.

    Thanks

    Option Explicit

    Sub changedhrcode()

    Dim lastrow, cell, cnt
    Dim txtDate As Date
    Dim txtName As String
    Dim txtDept As String

    cnt = 0
    lastrow = Range("B65536").End(xlUp).Row
    txtDate = InputBox("Enter Date You want the records searched for:",
    "Enter Date")
    txtName = InputBox("Enter Employee Name to search for:", "Enter Name")
    txtDept = InputBox("Enter HR Code to replace old:", "Enter Dept")
    For Each cell In Range("B1:B" & lastrow)
    If cell.Value = txtDate And LCase(cell.Offset(0, 1).Value) =
    LCase(txtName) Then
    cell.Offset(0, 2).Value = txtDept
    cnt = cnt + 1
    End If
    Next cell
    If cnt > 0 Then
    MsgBox "Number of records updated: " & cnt
    Else
    MsgBox "Info Not Found"
    End If

    End Sub


  2. #2
    Harlan Grove
    Guest

    Re: help with StrReverse function

    RompStar wrote...
    ....
    >But bascially I wanted it to work in a way so that if
    >
    >Someone enters in search
    >
    >Jim Smith
    >or
    >Smith Jim

    ....

    Bad idea. What if each of the following were names (first last) of
    employees?

    Hunter Thomas
    Thomas Hunter
    Parker Jordan
    Jordan Parker
    Kim Lee
    Lee Kim

    How would you handle false matches? Better to stick with normal
    conventions - first middle last (spaces only between names) and last,
    first middle (comma immediately after last name when it's first).

    As for your macro code, there's no StrReverse in it, and it runs just
    fine for me.


  3. #3
    RompStar
    Guest

    Re: help with StrReverse function

    ok, I'll stick with what I have :- )

    thanks


+ 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