You are on page 1of 30

Sub LoadData() ' ' LoadData Macro ' Loads Raw Data '

' ChDir _ "T:\IT&N\CND&D\CNP\Switching and Services\Mobile data\OUKBlackberry\IPCapacityMonitoring\NetTunerStats" Workbooks.OpenText Filename:= _ "T:\IT&N\CND&D\CNP\Switching and Services\Mobile data\OUKBlackberry\IPCapacityMonitoring\NetTunerStats\BBBristol.xls" _ , Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _ xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _ Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _ Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), _ Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1), Array(15 _ , 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1), Array(21, 1), _ Array(22, 1), Array(23, 1), Array(24, 1), Array(25, 1)), TrailingMinusNumbers:=True Columns("D:E").Select Columns("F:F").ColumnWidth = 15.14 Selection.Delete Shift:=xlToLeft Columns("E:V").Select Selection.Delete Shift:=xlToLeft Columns("A:D").Select Selection.Copy Windows("RawDataSummary.xlsm").Activate

Worksheets(1).Activate Range("A1").Select ActiveSheet.Paste Columns("A:D").Select Columns("A:D").EntireColumn.AutoFit

ChDir _ "T:\IT&N\CND&D\CNP\Switching and Services\Mobile data\OUKBlackberry\IPCapacityMonitoring\NetTunerStats" Workbooks.OpenText Filename:= _ "T:\IT&N\CND&D\CNP\Switching and Services\Mobile data\OUKBlackberry\IPCapacityMonitoring\NetTunerStats\BBBirmingham.xls" _ , Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _ xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _ Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _ Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), _ Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1), Array(15 _ , 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1), Array(21, 1), _ Array(22, 1), Array(23, 1), Array(24, 1), Array(25, 1)), TrailingMinusNumbers:=True Columns("D:E").Select Columns("F:F").ColumnWidth = 15.14 Selection.Delete Shift:=xlToLeft Columns("E:V").Select Selection.Delete Shift:=xlToLeft Columns("A:D").Select Selection.Copy

Windows("RawDataSummary.xlsm").Activate Worksheets(2).Activate Range("A1").Select ActiveSheet.Paste Columns("A:D").Select Columns("A:D").EntireColumn.AutoFit

ChDir _ "T:\IT&N\CND&D\CNP\Switching and Services\Mobile data\OUKBlackberry\IPCapacityMonitoring\NetTunerStats" Workbooks.OpenText Filename:= _ "T:\IT&N\CND&D\CNP\Switching and Services\Mobile data\OUKBlackberry\IPCapacityMonitoring\NetTunerStats\BBNUL.xls" _ , Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _ xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _ Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _ Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), _ Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1), Array(15 _ , 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1), Array(21, 1), _ Array(22, 1), Array(23, 1), Array(24, 1), Array(25, 1)), TrailingMinusNumbers:=True Columns("D:E").Select Columns("F:F").ColumnWidth = 15.14 Selection.Delete Shift:=xlToLeft Columns("E:V").Select Selection.Delete Shift:=xlToLeft Columns("A:D").Select

Selection.Copy Windows("RawDataSummary.xlsm").Activate Worksheets(3).Activate Range("A1").Select ActiveSheet.Paste Columns("A:D").Select Columns("A:D").EntireColumn.AutoFit

ChDir _ "T:\IT&N\CND&D\CNP\Switching and Services\Mobile data\OUKBlackberry\IPCapacityMonitoring\NetTunerStats" Workbooks.OpenText Filename:= _ "T:\IT&N\CND&D\CNP\Switching and Services\Mobile data\OUKBlackberry\IPCapacityMonitoring\NetTunerStats\BBMansfield.xls" _ , Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _ xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _ Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _ Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), _ Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1), Array(15 _ , 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1), Array(21, 1), _ Array(22, 1), Array(23, 1), Array(24, 1), Array(25, 1)), TrailingMinusNumbers:=True Columns("D:E").Select Columns("F:F").ColumnWidth = 15.14 Selection.Delete Shift:=xlToLeft Columns("E:V").Select Selection.Delete Shift:=xlToLeft

Columns("A:D").Select Selection.Copy Windows("RawDataSummary.xlsm").Activate Worksheets(4).Activate Range("A1").Select ActiveSheet.Paste Columns("A:D").Select Columns("A:D").EntireColumn.AutoFit

ChDir _ "T:\IT&N\CND&D\CNP\Switching and Services\Mobile data\OUKBlackberry\IPCapacityMonitoring\NetTunerStats" Workbooks.OpenText Filename:= _ "T:\IT&N\CND&D\CNP\Switching and Services\Mobile data\OUKBlackberry\IPCapacityMonitoring\NetTunerStats\BBLeicester.xls" _ , Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _ xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _ Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _ Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), _ Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1), Array(15 _ , 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1), Array(21, 1), _ Array(22, 1), Array(23, 1), Array(24, 1), Array(25, 1)), TrailingMinusNumbers:=True Columns("D:E").Select Columns("F:F").ColumnWidth = 15.14 Selection.Delete Shift:=xlToLeft Columns("E:V").Select

Selection.Delete Shift:=xlToLeft Columns("A:D").Select Selection.Copy Windows("RawDataSummary.xlsm").Activate Worksheets(5).Activate Range("A1").Select ActiveSheet.Paste Columns("A:D").Select Columns("A:D").EntireColumn.AutoFit

ChDir _ "T:\IT&N\CND&D\CNP\Switching and Services\Mobile data\OUKBlackberry\IPCapacityMonitoring\NetTunerStats" Workbooks.OpenText Filename:= _ "T:\IT&N\CND&D\CNP\Switching and Services\Mobile data\OUKBlackberry\IPCapacityMonitoring\NetTunerStats\BBLuton.xls" _ , Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _ xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _ Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _ Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), _ Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1), Array(15 _ , 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1), Array(21, 1), _ Array(22, 1), Array(23, 1), Array(24, 1), Array(25, 1)), TrailingMinusNumbers:=True Columns("D:E").Select Columns("F:F").ColumnWidth = 15.14 Selection.Delete Shift:=xlToLeft

Columns("E:V").Select Selection.Delete Shift:=xlToLeft Columns("A:D").Select Selection.Copy Windows("RawDataSummary.xlsm").Activate Worksheets(6).Activate Range("A1").Select ActiveSheet.Paste Columns("A:D").Select Columns("A:D").EntireColumn.AutoFit

End Sub

Sub test() ' ' test Macro '

' Range("G1").Select End Sub

Sub ChangeDates()

Dim strDate As String Dim intDateLength As Integer Dim intMonth As Integer Dim intDay As Integer Dim intYear As Integer Dim intWhereIsTheSpace As Integer Dim intWhereIsTheColon As Integer Dim intHourLength As Integer Dim strHour As String Dim strMinute As String Dim strResult As String

Range("G2").Activate

Do Until ActiveCell.Offset(0, -6).Value = Empty If ActiveCell.Value = Empty Then

strDate = ActiveCell.Offset(0, -6).Value intDateLength = Len(strDate) intMonth = getMonth(Left(strDate, 3))

If InStr(strDate, ",") = 7 Then intDay = Mid(strDate, 5, 2) intYear = Mid(strDate, 9, 4)

Else intDay = Mid(strDate, 5, 1) intYear = Mid(strDate, 8, 4)

End If

intWhereIsTheSpace = InStr(11, strDate, " ", vbTextCompare) intWhereIsTheColon = InStr(11, strDate, ":")

intHourLength = intWhereIsTheColon - intWhereIsTheSpace - 1

intWhereIsTheSpace = intWhereIsTheSpace + 1 intWhereIsTheColon = intWhereIsTheColon + 1

strHour = Mid(strDate, intWhereIsTheSpace, intHourLength) If Right(strDate, 2) = "PM" Then If strHour <> 12 Then strHour = CStr(CInt(strHour) + 12)

End If Else If strHour = "12" Then strHour = "00" End If

End If

strMinute = Mid(strDate, intWhereIsTheColon, 2)

strResult = intMonth & "/" & intDay & "/" & intYear & " " & strHour & ":" & strMinute & ":00"

ActiveCell.Value = strResult End If

ActiveCell.Offset(1, 0).Activate

Loop

End Sub

Public Function getMonth(ByVal strMonth As String) Dim intMonth As Integer Select Case strMonth

Case "Jan" intMonth = 1 Case "Feb" intMonth = 2 Case "Mar" intMonth = 3 Case "Apr" intMonth = 4 Case "May" intMonth = 5 Case "Jun" intMonth = 6 Case "Jul" intMonth = 7 Case "Aug" intMonth = 8 Case "Sep" intMonth = 9 Case "Oct" intMonth = 10 Case "Nov" intMonth = 11 Case "Dec" intMonth = 12 End Select

getMonth = intMonth

End Function

Sub Date_Conversion()

Dim strDate As String Dim intDateLength As Integer Dim intMonth As Integer Dim intDay As Integer Dim intYear As Integer Dim intWhereIsTheSpace As Integer Dim intWhereIsTheColon As Integer Dim intHourLength As Integer Dim strHour As String Dim strMinute As String Dim strResult As String

Range("G2").Activate

Do Until ActiveCell.Offset(0, -6).Value = Empty If ActiveCell.Value = Empty Then

strDate = ActiveCell.Offset(0, -6).Value intDateLength = Len(strDate) intMonth = getMonth(Left(strDate, 3))

If InStr(strDate, ",") = 7 Then intDay = Mid(strDate, 5, 2) intYear = Mid(strDate, 9, 4)

Else intDay = Mid(strDate, 5, 1) intYear = Mid(strDate, 8, 4)

End If

intWhereIsTheSpace = InStr(11, strDate, " ", vbTextCompare) intWhereIsTheColon = InStr(11, strDate, ":")

intHourLength = intWhereIsTheColon - intWhereIsTheSpace - 1

intWhereIsTheSpace = intWhereIsTheSpace + 1 intWhereIsTheColon = intWhereIsTheColon + 1

strHour = Mid(strDate, intWhereIsTheSpace, intHourLength) If Right(strDate, 2) = "PM" Then If strHour <> 12 Then strHour = CStr(CInt(strHour) + 12)

End If Else If strHour = "12" Then strHour = "00"

End If

End If

strMinute = Mid(strDate, intWhereIsTheColon, 2)

strResult = intMonth & "/" & intDay & "/" & intYear & " " & strHour & ":" & strMinute & ":00"

ActiveCell.Value = strResult End If

ActiveCell.Offset(1, 0).Activate

Loop

End Sub

Public Function getMonth(ByVal strMonth As String) Dim intMonth As Integer Select Case strMonth Case "Jan" intMonth = 1 Case "Feb" intMonth = 2 Case "Mar" intMonth = 3 Case "Apr" intMonth = 4 Case "May" intMonth = 5 Case "Jun" intMonth = 6 Case "Jul" intMonth = 7 Case "Aug" intMonth = 8 Case "Sep" intMonth = 9 Case "Oct" intMonth = 10 Case "Nov" intMonth = 11 Case "Dec" intMonth = 12

End Select

getMonth = intMonth

End Function

Sub ChangeDates()

Dim strDate As String Dim intDateLength As Integer Dim intMonth As Integer Dim intDay As Integer Dim intYear As Integer Dim intWhereIsTheSpace As Integer Dim intWhereIsTheColon As Integer Dim intHourLength As Integer Dim strHour As String Dim strMinute As String Dim strResult As String

Range("G2").Activate

Do Until ActiveCell.Offset(0, -6).Value = Empty If ActiveCell.Value = Empty Then

strDate = ActiveCell.Offset(0, -6).Value intDateLength = Len(strDate) intMonth = getMonth(Left(strDate, 3))

If InStr(strDate, ",") = 7 Then intDay = Mid(strDate, 5, 2) intYear = Mid(strDate, 9, 4)

Else intDay = Mid(strDate, 5, 1) intYear = Mid(strDate, 8, 4)

End If

intWhereIsTheSpace = InStr(11, strDate, " ", vbTextCompare) intWhereIsTheColon = InStr(11, strDate, ":")

intHourLength = intWhereIsTheColon - intWhereIsTheSpace - 1

intWhereIsTheSpace = intWhereIsTheSpace + 1 intWhereIsTheColon = intWhereIsTheColon + 1

strHour = Mid(strDate, intWhereIsTheSpace, intHourLength) If Right(strDate, 2) = "PM" Then If strHour <> 12 Then strHour = CStr(CInt(strHour) + 12)

End If

Else If strHour = "12" Then strHour = "00" End If

End If

strMinute = Mid(strDate, intWhereIsTheColon, 2)

strResult = intMonth & "/" & intDay & "/" & intYear & " " & strHour & ":" & strMinute & ":00"

ActiveCell.Value = strResult End If

ActiveCell.Offset(1, 0).Activate

Loop

End Sub

Public Function getMonth(ByVal strMonth As String) Dim intMonth As Integer Select Case strMonth Case "Jan" intMonth = 1 Case "Feb" intMonth = 2 Case "Mar" intMonth = 3 Case "Apr" intMonth = 4 Case "May" intMonth = 5 Case "Jun" intMonth = 6 Case "Jul" intMonth = 7 Case "Aug" intMonth = 8 Case "Sep" intMonth = 9 Case "Oct" intMonth = 10 Case "Nov"

intMonth = 11 Case "Dec" intMonth = 12 End Select

getMonth = intMonth

End Function

' Populate_Max_Pool_utilize Macro

Dim varMaxPool As Variant

Windows("APN_IP_Usage_1.27.xlsm").Activate For i = 4 To 15 Set sh = Sheets(i) sh.Activate Range("I2").Activate

Do Until ActiveCell.Offset(0, -3).Value = Empty

If ActiveCell.Value = Empty Then

For j = 1 To 100

For k = 1 To 96 ActiveCell.Value = WorksheetFunction.Max(ActiveCell.Offset((j * 96 - 1), -3).Value, ActiveCell.Offset(96 * j, -3)) ActiveCell.Offset(1, 0).Activate Next k

Next j

ActiveCell.Offset(1, 0).Activate End If Loop Next i End Sub

Sub Populate_Trend_equation_Values()

' ActiveChart.SeriesCollection(1).Trendlines(1).DataLabel.Text Dim sh As Worksheet Dim ChActChart As Chart Dim SerActSeriesCol As SeriesCollection

Set sh = Sheets(3) sh.Activate

' Set ChActChart = ChartObjects("Chart 1") ' Set SerActSeries = SeriesCollection(1)

ActiveSheet.ChartObjects("Chart 3").Activate 'ChActChart.SeriesCollection(1).Trendlines(1).Datalable.Text ' ActiveChart.SeriesCollection(1).Trendline(1).Activate

' ActiveSheet.ChartObjects("Chart 3).Chart.SeriesCollection(1).Trendlines(1). Dim treLineAll As Trendlines ' treLineAll = ActiveChart.ChartObjects

Dim ObjTrendLine As Object Dim mySeriesCollection As SeriesCollection Dim myTrendlines As Trendlines Dim myTrendLine As Trendline Dim TrendActiveTrendLine As Trendline Dim strTrendLabel As String

myTrendLine = ActiveChart.SeriesCollection(3)

strTrendLabel = TrendActiveTrendLine.DataLabel

' ActiveChaRT.SeriesCollection(1).

End Sub

Sub TestDataLoad() ' ' TestDataLoad Macro

Dim strReportFileName As String Dim strRawData1 As String Dim strRawData2 As String Dim strRawData3 As String Dim strRawData4 As String Dim strRawData5 As String Dim strRawData6 As String Dim strRawDataPath As String Dim strRawDataFullPath As String

Dim strRawDataFile As String

Dim intFileNum As Integer

strReportFileName = "APN_IP_Pool_Utilization_1.04.xlsm" strRawDataPath = "E:\My Work Documents\Day to Day Work\Reports\Raw_Data\APN\Orange Internet\"

'strRawDataName1 = "OIBirmingham.xls" 'strRawDataName2 = "OIBristol.xls" 'strRawDataName3 = "OILeicester.xls" 'strRawDataName4 = "OILuton.xls" 'strRawDataName5 = "OIMansfield.xls" 'strRawDataName6 = "OINUL.xls"

Dim intSheetNum As Integer

'Dim oExcel As Excel.Application 'Dim oWB As Workbook 'Set oExcel = New Excel.Application ' Set oWB = oExcel.Workbooks.Open(E:\folder)

For i = 1 To 6

intSheetNum = 2 * i + 3 intFileNum = i strRawDataFile = strRawFileName(intFileNum)

strRawDataFullPath = strRawDataPath & strRawDataFile

Workbooks.Open (strRawDataFullPath) Windows(strRawDataFile).Activate Range("A2").Select Range(Selection, Selection.End(xlDown)).Select Selection.Copy Windows(strReportFileName).Activate Sheets(intSheetNum).Activate Range("A2").Select Selection.End(xlDown).Select Selection.Offset(1).Select ActiveSheet.Paste

Windows(strRawDataFile).Activate Range("B2").Activate Range(Selection, Selection.End(xlDown)).Select Selection.Copy Windows(strReportFileName).Activate Sheets(intSheetNum).Activate Range("B2").Select Selection.End(xlDown).Select Selection.Offset(1).Select ActiveSheet.Paste

Windows(strRawDataFile).Activate Range("C2").Activate

Range(Selection, Selection.End(xlDown)).Select Selection.Copy Windows(strReportFileName).Activate Sheets(intSheetNum).Activate Range("C2").Select Selection.End(xlDown).Select Selection.Offset(1).Select ActiveSheet.Paste

Windows(strRawDataFile).Activate Range("F2").Activate Range(Selection, Selection.End(xlDown)).Select Selection.Copy Windows(strReportFileName).Activate Sheets(intSheetNum).Activate Range("D2").Select Selection.End(xlDown).Select Selection.Offset(1).Select ActiveSheet.Paste

Next i

End Sub

Public Function strRawFileName(ByRef intFileNum As Integer)

'Dim intFileNum As Integer ' Dim strRawFileName As Scenario Select Case intFileNum Case 1 strRawFileName = "OIBirmingham.xls" Case 2 strRawFileName = "OIBristol.xls" Case 3 strRawFileName = "OILeicester.xls" Case 4 strRawFileName = "OILuton.xls" Case 5 strRawFileName = "OIMansfield.xls" Case 6 strRawFileName = "OINUL.xls"

End Select

End Function

You might also like