johnny_raman
New Member
- Joined
- Mar 26, 2014
- Messages
- 22
Hi,
I am trying to run 2 codes one after the other but wont run.
I am able to run it separately which i have no issues. Below is the code i used to run both.
____________________________________________________________________________________
____________________________________________________________________________________
I am trying to run 2 codes one after the other but wont run.
I am able to run it separately which i have no issues. Below is the code i used to run both.
Code:
Sub Run_Both
Call ADDCLM
Call Temp
End Sub
____________________________________________________________________________________
Code:
Sub ADDCLM()
On Error Resume Next
Dim B737_BBJ_Row As Long
Dim B737_BBJ_Clm As Long
Table1 = ActiveSheet.Range("K2:K2000") ' VLOOKUP VALUE Column
Table2 = ActiveSheet.Range("XFC2:XFC66") ' Range of VLOOKUP ARRAY
B737_BBJ_Row = ActiveSheet.Range("AD2").Row ' Change AD2 with the cell from where you need to start populating the VLOOKUP DATA
B737_BBJ_Clm = ActiveSheet.Range("AD2").Column
For Each cl In Table1
ActiveSheet.Cells(B737_BBJ_Row, B737_BBJ_Clm) = Application.WorksheetFunction.VLookup(cl, Table2, 1, False)
B737_BBJ_Row = B737_BBJ_Row + 1
Next cl
On Error Resume Next
Dim Territory_List_Row As Long
Dim Territory_List_Clm As Long
Table1 = ActiveSheet.Range("AA2:AA2000") ' VLOOKUP VALUE Column
Table2 = ActiveSheet.Range("XFD2:XFD66") ' Range of VLOOKUP ARRAY
Territory_List_Row = ActiveSheet.Range("AE2").Row ' Change AE2 with the cell from where you need to start populating the VLOOKUP DATA
Territory_List_Clm = ActiveSheet.Range("AE2").Column
For Each cl In Table1
ActiveSheet.Cells(Territory_List_Row, Territory_List_Clm) = Application.WorksheetFunction.VLookup(cl, Table2, 1, False)
Territory_List_Row = Territory_List_Row + 1
Next cl
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
With ActiveSheet.UsedRange
.AutoFilter 15, "B737"
.AutoFilter 30, "<>"
If .Cells(Rows.Count, 15).End(xlUp).Row > 1 Then
.Columns(15).Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlVisible).Value = "B737 BBJ"
End If
.Parent.AutoFilterMode = False
.AutoFilter 15, "Non Aircraft Specific"
.AutoFilter 2, Array("Amsterdam", "Dubai", "Shanghai", "UK Burgess Hill"), xlFilterValues
If .Cells(Rows.Count, 15).End(xlUp).Row > 1 Then
.Columns(15).Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlVisible).Value = "Others"
End If
.Parent.AutoFilterMode = False
.AutoFilter 2, Array("Dallas", "Bombardier - Montreal", "NETC", "BBD Dallas", "Embraer CAE Brazil", "Embraer CAE Dallas"), xlFilterValues
.AutoFilter 31, ""
If .Cells(Rows.Count, 15).End(xlUp).Row > 1 Then
.Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlVisible).EntireRow.Delete
End If
.Parent.AutoFilterMode = False
.AutoFilter 2, Array("Dallas", "Bombardier - Montreal", "NETC", "BBD Dallas", "Embraer CAE Brazil", "Embraer CAE Dallas"), xlFilterValues
.AutoFilter 31, "<>"
If .Cells(Rows.Count, 15).End(xlUp).Row > 1 Then
.Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlVisible).Copy
Sheets("DATA_TRANSFER_FIRM").Select
Range("B2").Select
lMaxRows = Cells(Rows.Count, "A").End(xlUp).Row
Range("A" & lMaxRows + 1).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("B1").Select
ActiveSheet.Select
Range("A1").Select
End If
.Parent.AutoFilterMode = False
.AutoFilter 2, Array("Dallas", "Bombardier - Montreal", "NETC", "BBD Dallas", "Embraer CAE Brazil", "Embraer CAE Dallas"), xlFilterValues
.AutoFilter 31, "<>"
If .Cells(Rows.Count, 15).End(xlUp).Row > 1 Then
.Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlVisible).EntireRow.Delete
End If
.Parent.AutoFilterMode = False
.AutoFilter 2, Array("Dubai", "UK Burgess Hill"), xlFilterValues
.AutoFilter 14, "Maintenance*"
If .Cells(Rows.Count, 14).End(xlUp).Row > 1 Then
.Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlVisible).Copy
Sheets("BAT_HAT_MXT_Firmed").Select
Range("B2").Select
lMaxRows = Cells(Rows.Count, "A").End(xlUp).Row
Range("A" & lMaxRows + 1).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("A1").Select
ActiveSheet.Select
Range("A1").Select
End If
.Parent.AutoFilterMode = False
.AutoFilter 2, Array("Dubai", "UK Burgess Hill"), xlFilterValues
.AutoFilter 14, "Maintenance*"
If .Cells(Rows.Count, 14).End(xlUp).Row > 1 Then
.Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlVisible).EntireRow.Delete
End If
.Parent.AutoFilterMode = False
End With
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = xlCalculationAutomatic
End With
End Sub
____________________________________________________________________________________
Code:
Sub TEMP()
On Error Resume Next
Dim B737_BBJ_Row As Long
Dim B737_BBJ_Clm As Long
Table1 = ActiveSheet.Range("M2:M2000") ' VLOOKUP VALUE Column
Table2 = ActiveSheet.Range("XFC2:XFC66") ' Range of VLOOKUP ARRAY
B737_BBJ_Row = ActiveSheet.Range("AF2").Row ' Change AF2 with the cell from where you need to start populating the VLOOKUP DATA
B737_BBJ_Clm = ActiveSheet.Range("AF2").Column
For Each cl In Table1
ActiveSheet.Cells(B737_BBJ_Row, B737_BBJ_Clm) = Application.WorksheetFunction.VLookup(cl, Table2, 1, False)
B737_BBJ_Row = B737_BBJ_Row + 1
Next cl
On Error Resume Next
Dim Territory_List_Row As Long
Dim Territory_List_Clm As Long
Table1 = ActiveSheet.Range("AC2:AC2000") ' VLOOKUP VALUE Column
Table2 = ActiveSheet.Range("XFD2:XFD66") ' Range of VLOOKUP ARRAY
Territory_List_Row = ActiveSheet.Range("AG2").Row ' Change AG2 with the cell from where you need to start populating the VLOOKUP DATA
Territory_List_Clm = ActiveSheet.Range("AG2").Column
For Each cl In Table1
ActiveSheet.Cells(Territory_List_Row, Territory_List_Clm) = Application.WorksheetFunction.VLookup(cl, Table2, 1, False)
Territory_List_Row = Territory_List_Row + 1
Next cl
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
With ActiveSheet.UsedRange
.AutoFilter 15, "B737"
.AutoFilter 30, "<>"
If .Cells(Rows.Count, 15).End(xlUp).Row > 1 Then
.Columns(15).Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlVisible).Value = "B737 BBJ"
End If
.Parent.AutoFilterMode = False
.AutoFilter 17, "Non Aircraft Specific"
.AutoFilter 2, Array("Amsterdam", "Dubai", "Shanghai", "UK Burgess Hill"), xlFilterValues
If .Cells(Rows.Count, 17).End(xlUp).Row > 1 Then
.Columns(17).Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlVisible).Value = "Others"
End If
.Parent.AutoFilterMode = False
.AutoFilter 2, Array("Dallas", "Bombardier - Montreal", "NETC", "BBD Dallas", "Embraer CAE Brazil", "Embraer CAE Dallas"), xlFilterValues
.AutoFilter 33, ""
If .Cells(Rows.Count, 17).End(xlUp).Row > 1 Then
.Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlVisible).EntireRow.Delete
End If
.Parent.AutoFilterMode = False
.AutoFilter 2, Array("Dallas", "Bombardier - Montreal", "NETC", "BBD Dallas", "Embraer CAE Brazil", "Embraer CAE Dallas"), xlFilterValues
.AutoFilter 33, "<>"
If .Cells(Rows.Count, 17).End(xlUp).Row > 1 Then
.Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlVisible).Copy
Sheets("DATA_TRANSFER_TEMP").Select
Range("B2").Select
lMaxRows = Cells(Rows.Count, "A").End(xlUp).Row
Range("A" & lMaxRows + 1).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("B1").Select
ActiveSheet.Select
Range("A1").Select
End If
.Parent.AutoFilterMode = False
.AutoFilter 2, Array("Dallas", "Bombardier - Montreal", "NETC", "BBD Dallas", "Embraer CAE Brazil", "Embraer CAE Dallas"), xlFilterValues
.AutoFilter 33, "<>"
If .Cells(Rows.Count, 17).End(xlUp).Row > 1 Then
.Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlVisible).EntireRow.Delete
End If
.Parent.AutoFilterMode = False
.AutoFilter 2, Array("Dubai", "UK Burgess Hill"), xlFilterValues
.AutoFilter 16, "Maintenance*"
If .Cells(Rows.Count, 16).End(xlUp).Row > 1 Then
.Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlVisible).Copy
Sheets("BAT_HAT_MXT_Temps").Select
Range("B2").Select
lMaxRows = Cells(Rows.Count, "A").End(xlUp).Row
Range("A" & lMaxRows + 1).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("A1").Select
ActiveSheet.Select
Range("A1").Select
End If
.Parent.AutoFilterMode = False
.AutoFilter 2, Array("Dubai", "UK Burgess Hill"), xlFilterValues
.AutoFilter 14, "Maintenance*"
If .Cells(Rows.Count, 16).End(xlUp).Row > 1 Then
.Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlVisible).EntireRow.Delete
End If
.Parent.AutoFilterMode = False
End With
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = xlCalculationAutomatic
End With
MsgBox "Done"
End Sub
Last edited by a moderator: