0% found this document useful (0 votes)
56 views

Coding 2.2

This document contains the code for running a macro that performs the following key tasks: 1. Opens multiple input files, copies data from specific sheets to a template file, and clears certain columns. 2. Loops through the input files, copies additional data, and uses VLookup functions to populate trend data sheets based on criteria. 3. Pastes values to remove formulas from the trend data sheets after each iteration. The macro standardizes data from multiple files into a single template for analysis and trend reporting. It copies data, clears fields, loops through files, uses VLookup, and pastes values to populate trend sheets in an automated process.

Uploaded by

Shoib Ansari
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views

Coding 2.2

This document contains the code for running a macro that performs the following key tasks: 1. Opens multiple input files, copies data from specific sheets to a template file, and clears certain columns. 2. Loops through the input files, copies additional data, and uses VLookup functions to populate trend data sheets based on criteria. 3. Pastes values to remove formulas from the trend data sheets after each iteration. The macro standardizes data from multiple files into a single template for analysis and trend reporting. It copies data, clears fields, loops through files, uses VLookup, and pastes values to populate trend sheets in an automated process.

Uploaded by

Shoib Ansari
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 39

Private Sub TRDROP_Click()

End Sub

Private Sub DATATRAFFIC_Click()

End Sub

Private Sub CheckBox1_Click()

End Sub

Private Sub DAYTRAFFIC_Click()

End Sub

Private Sub DLQUAL_Click()

End Sub

Private Sub HOSR_Click()

End Sub

Private Sub Label2_Click()

End Sub

Private Sub Label5_Click()

End Sub

Private Sub SDBLOCK_Click()

End Sub

Private Sub SDDROP_Click()

End Sub

Private Sub TASR_Click()

End Sub

Private Sub TCHBLOCK_Click()

End Sub

Private Sub TCHDROP_Click()

End Sub

Private Sub ULQUAL_Click()

End Sub

Private Sub UserForm_Click()

End Sub

Private Sub UTIL_Click()

End Sub

Private Sub RUN_Click()

Application.ScreenUpdating = False Dim Response As VbMsgBoxResult Dim TB, TR, SR, SB, H, T, DL, UL, DTRAF, BTRAFF, S, j, k, d1, d2, s1, s2, temp, datevar1, monthvar, mm As Integer Dim KPI, CellName, datevar As String Dim PeakValue, PeakTraffic, BBHtime As Double 'Dim datevar1 As Date DD = 0 mm = 0 monthvar = 0 'S = TB + TR + SR + SB + H + T + DL + UL + DTRAFF + BTRAFF

Workbooks.Open ("C:\MACRO\TrafficTrending\TEMPLATE\TEMP.xls") folderspec = "C:\MACRO\TrafficTrending\INPUT"

Dim FILENAMEARRAY() As Variant Dim datefilenamearray() As Variant

countoffile = 0 'Dim fs, f, f1, fc, S Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.GetFolder(folderspec) Set fc = f.Files For Each f1 In fc

S = f1.Name

DD = Mid(S, InStr(3, S, "UPE") + 4, 2) mm = Mid(S, InStr(3, S, "UPE") + 7, 2)

countoffile = countoffile + 1 ReDim Preserve FILENAMEARRAY(countoffile - 1) As Variant FILENAMEARRAY(countoffile - 1) = S ReDim Preserve datefilenamearray(countoffile - 1) As Variant datefilenamearray(countoffile - 1) = DD

If mm < monthvar Then 'monthvar = mm GoTo g Else If DD > datevar1 Then

datevar1 = DD monthvar = mm cof = countoffile

End If

End If

g:

Next

'lllllllllllllllllllllllllllllllllllllllllllllllll LOGfile = "C:\MACRO\TafficTrending\INPUT\" & FILENAMEARRAY(cof - 1) If LOGfile = "" Or LOGfile = "False" Then Exit Sub 'End If

'Windows("GSM_Town_Template.xlsx").Activate Workbooks.Open ("C:\MACRO\TrafficTrending\INPUT\" & FILENAMEARRAY(cof - 1))

Windows(FILENAMEARRAY(cof - 1)).Activate

Sheets("Peak hour data").Select '----------------------------------------------------

Cells.Select Selection.Copy

Windows("TEMP.xls").Activate Sheets("Sheet2").Select Cells(1, 1).Select

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

'&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

Sheets("TCHBLOCKING").Select Columns("A:A").Select Selection.ClearContents

Sheets("TCHDROP").Select Columns("A:A").Select Selection.ClearContents Sheets("SDDROP").Select Columns("A:A").Select Selection.ClearContents Sheets("SDBLOCK").Select Columns("A:A").Select Selection.ClearContents Sheets("TASR").Select Columns("A:A").Select

Selection.ClearContents Sheets("UTIL").Select Columns("A:A").Select Selection.ClearContents Sheets("24 HRS TRAFFIC").Select Columns("A:A").Select Selection.ClearContents Sheets("ULQUAL").Select Columns("A:A").Select Selection.ClearContents Sheets("DLQUAL").Select Columns("A:A").Select Selection.ClearContents Sheets("HOFR").Select Columns("A:A").Select Selection.ClearContents Sheets("TRDROP").Select Columns("A:A").Select Selection.ClearContents

Workbooks(FILENAMEARRAY(cof - 1)).Close SaveChanges:=False 'Workbooks("TEMP.xls").Close SaveChanges:=True

'&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &

Sheets("Sheet2").Select Rows("1:1").Select Selection.Delete Shift:=xlUp

Columns("B:B").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

LASTROW1 = ActiveCell.Row - 1 'Rows("1:1").Select

Range("A1:D" & LASTROW1).Select

Selection.Copy

Sheets("TCHBLOCKING").Select

Cells(1, 1).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

Sheets("TCHDROP").Select

Cells(1, 1).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

Sheets("SDDROP").Select

Cells(1, 1).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

Sheets("SDBLOCK").Select Cells(1, 1).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

Sheets("TASR").Select

Cells(1, 1).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Sheets("UTIL").Select

Cells(1, 1).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Sheets("24 HRS TRAFFIC").Select

Cells(1, 1).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

Sheets("ULQUAL").Select

Cells(1, 1).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

Sheets("DLQUAL").Select

Cells(1, 1).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

Sheets("HOFR").Select

Cells(1, 1).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

Sheets("TRDROP").Select

Cells(1, 1).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

Sheets("TCHBLOCKING").Select Columns("C:C").Select Selection.Delete Shift:=xlToLeft

Sheets("TCHDROP").Select

Columns("C:C").Select Selection.Delete Shift:=xlToLeft

Sheets("SDDROP").Select

Columns("C:C").Select Selection.Delete Shift:=xlToLeft

Sheets("SDBLOCK").Select Columns("C:C").Select Selection.Delete Shift:=xlToLeft

Sheets("TASR").Select Columns("C:C").Select Selection.Delete Shift:=xlToLeft

Sheets("UTIL").Select Columns("C:C").Select Selection.Delete Shift:=xlToLeft

Sheets("24 HRS TRAFFIC").Select Columns("C:C").Select Selection.Delete Shift:=xlToLeft

Sheets("ULQUAL").Select Columns("C:C").Select Selection.Delete Shift:=xlToLeft

Sheets("DLQUAL").Select Columns("C:C").Select Selection.Delete Shift:=xlToLeft

Sheets("HOFR").Select

Columns("C:C").Select Selection.Delete Shift:=xlToLeft

Sheets("TRDROP").Select

Cells(1, 1).Select

Columns("C:C").Select Selection.Delete Shift:=xlToLeft

'Sheets("DATATRAFFIC").Select

' Cells(1, 1).Select ' Columns("C:C").Select ' Selection.Delete Shift:=xlToLeft

'LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL

Windows("TEMP.xls").Activate Sheets("Sheet2").Select Cells.Select Selection.ClearContents

'Workbooks(FILENAMEARRAY(cof - 1)).Close SaveChanges:=False 'Workbooks("TEMP.xls").Close SaveChanges:=True

'ppppppppppppppppppppppppppppppppppppppppppppppppppppppp

COUNT_FILE = 1

Do While COUNT_FILE <= countoffile

LOGfile = "C:\MACRO\TafficTrending\INPUT\" & FILENAMEARRAY(COUNT_FILE - 1) If LOGfile = "" Or LOGfile = "False" Then Exit Sub 'End If

'Windows("GSM_Town_Template.xlsx").Activate Workbooks.Open ("C:\MACRO\TrafficTrending\INPUT\" & FILENAMEARRAY(COUNT_FILE - 1))

Windows(FILENAMEARRAY(COUNT_FILE - 1)).Activate

Sheets("Peak hour data").Select '----------------------------------------------------

Cells.Select Selection.Copy

Windows("TEMP.xls").Activate Sheets("Sheet2").Select Cells(1, 1).Select

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

Rows("1:1").Select Selection.Delete Shift:=xlUp

Columns("B:B").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

LASTROW = ActiveCell.Row - 1 Rows("1:1").Select

Windows(FILENAMEARRAY(COUNT_FILE - 1)).Activate Sheets("TOTAL NETWORK SHEET").Select Range("E4").Select Application.CutCopyMode = False Selection.Copy

datevar = Cells(4, 5).Value

Selection.Copy

'TCH BLOCKING***********

If trend.TCHBLOCK.Value = "True" Then Windows("TEMP.xls").Activate Sheets("TCHBLOCKING").Select Columns("B:B").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

LASTROW1 = ActiveCell.Row - 1

Rows("1:1").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

bc = ActiveCell.Column Cells(1, bc).Select

ActiveCell.Value = datevar

Cells(2, bc).Activate

Application.CutCopyMode = False ActiveCell.Value = _ "=VLOOKUP(B2,'[TEMP.xls]Sheet2'!$B:$AV,17,0)"

Selection.AutoFill Destination:=Range(Cells(2, bc), Cells(LASTROW1, bc))

Windows("TEMP.xls").Activate Sheets("TCHBLOCKING").Select Cells.Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False End If

'TCH DROP*************** If trend.TCHDROP.Value = "True" Then

Windows("TEMP.xls").Activate Sheets("TCHDROP").Select Columns("B:B").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

LASTROW1 = ActiveCell.Row - 1

Rows("1:1").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _

MatchCase:=False).Activate

bc = ActiveCell.Column Cells(1, bc).Select

ActiveCell.Value = datevar

Cells(2, bc).Activate

Application.CutCopyMode = False ActiveCell.Value = _ "=VLOOKUP(B2,'[TEMP.xls]Sheet2'!$B:$AV,23,0)"

Selection.AutoFill Destination:=Range(Cells(2, bc), Cells(LASTROW1, bc))

Windows("TEMP.xls").Activate Sheets("TCHDROP").Select Cells.Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

End If

'SD DROP***************

If trend.SDDROP.Value = "True" Then Windows("TEMP.xls").Activate Sheets("SDDROP").Select Columns("B:B").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

LASTROW1 = ActiveCell.Row - 1

Rows("1:1").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

bc = ActiveCell.Column Cells(1, bc).Select

ActiveCell.Value = datevar

Cells(2, bc).Activate

Application.CutCopyMode = False ActiveCell.Value = _ "=VLOOKUP(B2,'[TEMP.xls]Sheet2'!$B:$AV,21,0)"

Selection.AutoFill Destination:=Range(Cells(2, bc), Cells(LASTROW1, bc))

Windows("TEMP.xls").Activate Sheets("SDDROP").Select Cells.Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

End If

'SD BLOCK*************

If trend.SDBLOCK.Value = "True" Then Windows("TEMP.xls").Activate Sheets("SDBLOCK").Select Columns("B:B").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

LASTROW1 = ActiveCell.Row - 1

Rows("1:1").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

bc = ActiveCell.Column Cells(1, bc).Select

ActiveCell.Value = datevar

Cells(2, bc).Activate

Application.CutCopyMode = False ActiveCell.Value = _ "=VLOOKUP(B2,'[TEMP.xls]Sheet2'!$B:$AV,19,0)"

Selection.AutoFill Destination:=Range(Cells(2, bc), Cells(LASTROW1, bc))

Windows("TEMP.xls").Activate Sheets("SDBLOCK").Select Cells.Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

End If

'TASR****************

If trend.TASR.Value = "True" Then

Windows("TEMP.xls").Activate Sheets("TASR").Select Columns("B:B").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

LASTROW1 = ActiveCell.Row - 1

Rows("1:1").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

bc = ActiveCell.Column Cells(1, bc).Select

ActiveCell.Value = datevar

Cells(2, bc).Activate

Application.CutCopyMode = False ActiveCell.Value = _ "=VLOOKUP(B2,'[TEMP.xls]Sheet2'!$B:$AV,24,0)"

Selection.AutoFill Destination:=Range(Cells(2, bc), Cells(LASTROW1, bc))

Windows("TEMP.xls").Activate Sheets("TASR").Select Cells.Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

End If

'HOFR****************

If trend.HOSR.Value = "True" Then Windows("TEMP.xls").Activate Sheets("HOFR").Select Columns("B:B").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

LASTROW1 = ActiveCell.Row - 1

Rows("1:1").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _

LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

bc = ActiveCell.Column Cells(1, bc).Select

ActiveCell.Value = datevar

Cells(2, bc).Activate

Application.CutCopyMode = False ActiveCell.Value = _ "=VLOOKUP(B2,'[TEMP.xls]Sheet2'!$B:$AV,27,0)"

Selection.AutoFill Destination:=Range(Cells(2, bc), Cells(LASTROW1, bc))

Windows("TEMP.xls").Activate Sheets("HOFR").Select Cells.Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False 'S = 27

End If

'BBH TRAFFIC************

If trend.TRDROP.Value = "True" Then

Windows("TEMP.xls").Activate Sheets("TRDROP").Select Columns("B:B").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

LASTROW1 = ActiveCell.Row - 1

Rows("1:1").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

bc = ActiveCell.Column Cells(1, bc).Select

ActiveCell.Value = datevar

Cells(2, bc).Activate

Application.CutCopyMode = False ActiveCell.Value = _ "=VLOOKUP(B2,'[TEMP.xls]Sheet2'!$B:$AV,34,0)"

Selection.AutoFill Destination:=Range(Cells(2, bc), Cells(LASTROW1, bc))

Windows("TEMP.xls").Activate Sheets("TRDROP").Select Cells.Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

'Call Module1 'S=9

End If

'DL QUAL *************

If trend.DLQUAL.Value = "True" Then Windows("TEMP.xls").Activate Sheets("DLQUAL").Select Columns("B:B").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

LASTROW1 = ActiveCell.Row - 1

Rows("1:1").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

bc = ActiveCell.Column Cells(1, bc).Select

ActiveCell.Value = datevar

Cells(2, bc).Activate

Application.CutCopyMode = False ActiveCell.Value = _ "=VLOOKUP(B2,'[TEMP.xls]Sheet2'!$B:$AV,26,0)"

Selection.AutoFill Destination:=Range(Cells(2, bc), Cells(LASTROW1, bc))

Windows("TEMP.xls").Activate Sheets("DLQUAL").Select Cells.Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

'Call Module1 ' S = 10

End If

'UL QUAL""""""""""""

If trend.ULQUAL.Value = "True" Then

Windows("TEMP.xls").Activate Sheets("ULQUAL").Select Columns("B:B").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

LASTROW1 = ActiveCell.Row - 1

Rows("1:1").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

bc = ActiveCell.Column

Cells(1, bc).Select

ActiveCell.Value = datevar

Cells(2, bc).Activate

Application.CutCopyMode = False ActiveCell.Value = _ "=VLOOKUP(B2,'[TEMP.xls]Sheet2'!$B:$AV,25,0)"

Selection.AutoFill Destination:=Range(Cells(2, bc), Cells(LASTROW1, bc))

Windows("TEMP.xls").Activate Sheets("ULQUAL").Select Cells.Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

End If

'UTIL*************** If trend.UTIL.Value = "True" Then

Windows("TEMP.xls").Activate

Sheets("UTIL").Select Columns("B:B").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

LASTROW1 = ActiveCell.Row - 1

Rows("1:1").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

bc = ActiveCell.Column Cells(1, bc).Select

ActiveCell.Value = datevar

Cells(2, bc).Activate

Application.CutCopyMode = False ActiveCell.Value = _ "=VLOOKUP(B2,'[TEMP.xls]Sheet2'!$B:$BG,11,0)"

Selection.AutoFill Destination:=Range(Cells(2, bc), Cells(LASTROW1, bc))

Windows("TEMP.xls").Activate

Sheets("UTIL").Select Cells.Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

'Call Module1 'S = 10

End If

'*24 HRS TRAFFIC************************

If trend.DAYTRAFFIC.Value = "True" Then

Windows("TEMP.xls").Activate Sheets("24 HRS TRAFFIC").Select Columns("B:B").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

LASTROW1 = ActiveCell.Row - 1

Rows("1:1").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

bc = ActiveCell.Column Cells(1, bc).Select

ActiveCell.Value = datevar

Cells(2, bc).Activate

Application.CutCopyMode = False ActiveCell.Value = _ "=VLOOKUP(B2,'[TEMP.xls]Sheet2'!$B:$BG,55,0)"

Selection.AutoFill Destination:=Range(Cells(2, bc), Cells(LASTROW1, bc))

Windows("TEMP.xls").Activate Sheets("24 HRS TRAFFIC").Select Cells.Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

'Call Module1

'S = 10

End If

'*DATA TRAFFIC************************

If trend.DATATRAFFIC.Value = "True" Then

Windows("TEMP.xls").Activate Sheets("DATATRAFFIC").Select Columns("B:B").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

LASTROW1 = ActiveCell.Row - 1

Rows("1:1").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

bc = ActiveCell.Column Cells(1, bc).Select

ActiveCell.Value = datevar

Cells(2, bc).Activate

Application.CutCopyMode = False ActiveCell.Value = _ "=VLOOKUP(B2,'[TEMP.xls]Sheet2'!$B:$BG,54,0)"

Selection.AutoFill Destination:=Range(Cells(2, bc), Cells(LASTROW1, bc))

' Cells(1, (bc + 1)).Select ' ActiveCell.Value = datevar ' Cells(2, (bc + 1)).Activate ' ' ' ' Application.CutCopyMode = False ActiveCell.Value = _ "=VLOOKUP(B2,'[TEMP.xls]Sheet2'!$B:$AV,46,0)"

'Selection.AutoFill Destination:=Range(Cells(2, (bc + 1)), Cells(LASTROW1, (bc + 1)))

Windows("TEMP.xls").Activate Sheets("DATATRAFFIC").Select Cells.Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Windows("TEMP.xls").Activate Sheets("DATATRAFFIC").Select Columns("B:B").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

LASTROW1 = ActiveCell.Row - 1

Rows("1:1").Select Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False).Activate

bc = ActiveCell.Column Cells(1, bc).Select

ActiveCell.Value = datevar

Cells(2, bc).Activate

Application.CutCopyMode = False ActiveCell.Value = _ "=VLOOKUP(B2,'[TEMP.xls]Sheet2'!$B:$BG,53,0)"

Selection.AutoFill Destination:=Range(Cells(2, bc), Cells(LASTROW1, bc))

'

Cells(1, (bc + 1)).Select ' ActiveCell.Value = datevar ' Cells(2, (bc + 1)).Activate

' ' ' ' Application.CutCopyMode = False ActiveCell.Value = _ "=VLOOKUP(B2,'[TEMP.xls]Sheet2'!$B:$AV,46,0)"

' Selection.AutoFill Destination:=Range(Cells(2, (bc + 1)), Cells(LASTROW1, (bc + 1)))

Windows("TEMP.xls").Activate Sheets("DATATRAFFIC").Select Cells.Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

'Call Module1 'S = 10

End If

Windows("TEMP.xls").Activate Sheets("Sheet2").Select Cells.Select Selection.ClearContents

Workbooks(FILENAMEARRAY(COUNT_FILE - 1)).Close SaveChanges:=False 'activeWorkbooks.Close SaveChanges:=False COUNT_FILE = COUNT_FILE + 1

Loop

Windows("TEMP.xls").Activate

Cells.Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False

ChDir "C:\MACRO\TrafficTrending\OUTPUT\" ActiveWorkbook.SaveAs Filename:= _

"C:\MACRO\TrafficTrending\OUTPUT\TRAFFIC_TREND" & "_" & datevar1 & "_" & monthvar, FileFormat:=xlNormal, _ Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _ CreateBackup:=False

'Workbooks("TEMP.xls").Close SaveChanges:=False Workbooks("TRAFFIC_TREND" & "_" & datevar1 & "_" & monthvar & ".xls").Close SaveChanges:=True

'End Sub

End Sub

You might also like