Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Attribute VB_Name = "Ä£¿é1"
- Sub AutoFill()
- Dim RowNumber As Integer
- Dim IncidentId As String
- Dim CategoryTypeOneAtColG As String
- Dim CategoryTypeTwoAtColG As String
- CategoryTypeOneAtColG = "1.Job"
- CategoryTypeTwoAtColG = "1.AP"
- For RowNumber = 2 To Worksheets("AP_JOB").Range("A65536").End(xlUp).Row
- IncidentId = Worksheets("AP_JOB").Cells(RowNumber, "A").Value
- If Worksheets("AP_JOB").Cells(RowNumber, "G").Value = CategoryTypeOneAtColG Then
- Worksheets("AP_JOB").Cells(RowNumber, "D").Value = GetPointOfCategoryOne(IncidentId)
- Else
- Worksheets("AP_JOB").Cells(RowNumber, "D").Value = GetPointOfCategoryTwo(IncidentId)
- End If
- Next RowNumber
- End Sub
- Public Function GetPointOfCategoryOne(IncidentId As String)
- Dim Point As String
- Dim IncidentName As String
- Dim RowNumber As Integer
- For RowNumber = 2 To Worksheets("ALL").Range("A65535").End(xlUp).Row
- If Worksheets("ALL").Cells(RowNumber, "A").Value = IncidentId Then
- IncidentName = Replace(Worksheets("ALL").Cells(RowNumber, "C").Value, "¡¡", " ")
- GetPointOfCategoryOne = Left(IncidentName, InStr(Trim(IncidentName), " ") - 1)
- Exit For
- End If
- Next RowNumber
- End Function
- Public Function GetPointOfCategoryTwo(IncidentId As String)
- Dim Point As String
- Dim LogString As String
- Dim RowNumber As Integer
- For RowNumber = 2 To Worksheets("ALL").Range("A65535").End(xlUp).Row
- If Worksheets("ALL").Cells(RowNumber, "A").Value = IncidentId Then
- LogString = Worksheets("ALL").Cells(RowNumber, "AB").Value
- GetPointOfCategoryTwo = FindLogName(LogString)
- Exit For
- End If
- Next RowNumber
- End Function
- Public Function FindLogName(LogString As String)
- Dim LogSuffixIndex As Integer
- Dim NearestSlashIndex As Integer
- Dim TmpStr As String
- DotLogIndex = InStr(LogString, ".log")
- TmpStr = Mid(LogString, 1, DotLogIndex + 3)
- NearestSlashIndex = InStrRev(TmpStr, "/")
- FindLogName = Mid(TmpStr, NearestSlashIndex + 1)
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement