PDA

View Full Version : exemple of macro VBA code source commande ZEOL



adam07
2013-01-12, 11:12 PM
Sub MYZEOL()
Dim FILENAME As String
Dim t As String, s As String, R As String
Dim x As Integer, Y As Integer, I As Integer
FILENAME = Application.GetOpenFilename("Text Files (*.*), *.txt,All Files (*.*),*.*", , "Log Filename")
If FILENAME = "" Or FILENAME = "False" Then End
'Cells.Select
'Selection.NumberFormat = "@"

For I = 1 To Len(FILENAME)
If Mid(FILENAME, I, 1) = "\" Then Y = I
Next I
't = Mid(filename, y + 1, Len(filename) - y + 1)
'ActiveSheet.Name = t
Open FILENAME For Input As #1
x = 2
Sheets("ZEOL").Select
Cells.Clear
With Application
.Calculation = xlManual
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
Range("A1") = "BSC NAME"
Range("B1") = "BCF NUM"
Range("C1") = "BTS NUM"
Range("D1") = "TYPE OF ALM"
Range("E1") = "DATE"
Range("F1") = "TIME"
Range("G1") = "URGENCY LEVEL"
Range("H1") = "ALARM/CANCEL"
Range("I1") = "TRX NUM"
Range("J1") = "BTS NAME"
Range("K1") = "ALARM"
Range("L1") = "ALARM NUMBER"
Range("M1") = "ALARM DESCRIPTION 1"
Range("N1") = "ALARM DESCRIPTION 2"
Range("O1") = "SUPLEMENTORY INFO"
Range("A1:Q1").HorizontalAlignment = xlCenter
Range("A1:Q1").Font.Bold = True
Do Until EOF(1)
On Error GoTo P
Line Input #1, t
If InStr(t, "*") = 1 Then
Cells(x, 1) = Trim(Mid(R, 12, 13))
Cells(x, 2) = Trim(Mid(R, 25, 8))
Cells(x, 3) = Trim(Mid(R, 35, 8))
Cells(x, 4) = Trim(Mid(R, 46, 8))
Cells(x, 5) = Trim(Mid(R, 56, 12))
Cells(x, 6) = Trim(Mid(R, 68))
Cells(x, 7) = Trim(Mid(t, 1, 4))
Cells(x, 8) = Trim(Mid(t, 5, 7))
Cells(x, 9) = Trim(Mid(t, 12, 11))
Cells(x, 10) = Trim(Mid(t, 35, 22))
Line Input #1, t
Cells(x, 11) = Trim(Mid(t, 5, 5))
Cells(x, 12) = Trim(Mid(t, 12, 4))
Cells(x, 13) = Trim(Mid(t, 17))

Line Input #1, t
Cells(x, 14) = Trim(Mid(t, 17))

If Cells(x, 14) = "LAPD FAILURE" Then
Cells(x, 11) = Trim(Mid(t, 5, 5))
Cells(x, 12) = Trim(Mid(t, 12, 4))
Cells(x, 13) = "LAPD FAILURE"
End If

Line Input #1, t
Cells(x, 15) = Trim(Mid(t, 17))


x = x + 1
Else
R = t
End If
P:
Loop
Cells.Select
Selection.Font.Size = 8
Selection.Font.Name = "TAHOMA"
Selection.Columns.AutoFit
Selection.AutoFilter
Close #1
MsgBox ("ZEOL Done ....")
End Sub