Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. With ThisWorkbook.Worksheets("Sheet2").Columns("A")
  2. Set rFound = .Find(lJobCode, .Cells(.Cells.Count), xlValues, xlWhole)
  3.  
  4. If Not rFound Is Nothing Then
  5. If ThisWorkbook.Worksheets("Sheet2").Cells(rFound.Row, 3).Value = lCC Then
  6. matched = True
  7.  
  8. Public Function LocateFind() As Range
  9.  
  10. Dim rngCell As Range
  11. Dim rngRangeToLookAt As Range
  12.  
  13. Set rngRangeToLookAt = Range("A1:A100")
  14. Set LocateFind = rngRangeToLookAt.Find("YourValueHere", searchdirection:=xlPrevious)
  15.  
  16. End Function
  17.  
  18. Option Explicit
  19.  
  20. Sub tgr()
  21. Dim rFound As Range
  22. Dim lJobCode As String, lFLSA As String, lCC As String
  23. Dim sFirst As String
  24. Dim sResults As String
  25. Dim sh As Worksheet
  26. Dim matched As Boolean
  27. Dim Y As String, Z As String
  28.  
  29. lJobCode = Application.InputBox("Please provide a job code", "Job Code", Type:=2)
  30. lCC = Application.InputBox("Please enter in a cost-center", "CC", Type:=2)
  31.  
  32. If lJobCode = "False" Or lCC = "False" Then Exit Sub 'Pressed cancel
  33. Set sh = Sheets("Sheet1")
  34.  
  35. With ThisWorkbook.Worksheets("Sheet2").Columns("A")
  36. Set rFound = .Find(lJobCode, .Cells(.Cells.Count), xlValues, xlWhole)
  37. If Not rFound Is Nothing Then
  38. If ThisWorkbook.Worksheets("Sheet2").Cells(rFound.Row, 3).Value = lCC Then
  39. matched = True
  40.  
  41. If rFound.Offset(, 4).Value = "Exempt" And Y = 0 Then
  42. MsgBox "Exempt roles ...."
  43. Y = 1
  44. Exit Sub
  45. End If
  46.  
  47. If rFound.Offset(, 5).Value = "Eligible - Employee Level" And Z = 0 Then
  48. MsgBox "This job is only eligible at the employee level"
  49. Z = 1
  50. Exit Sub
  51. End If
  52.  
  53. If Not matched Then MsgBox "Job Code (" & lJobCode & ") found, but not eligible for this cost-center"
  54. Else
  55. MsgBox "Job Code (" & lJobCode & ") not eligible."
  56. End If
  57. End With
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement