Documente Academic
Documente Profesional
Documente Cultură
'Application.ScreenUpdating = False
Application.DisplayAlerts = False
For i = 2 To lngRow
Worksheets("Real").Cells(i, 63).value = Worksheets("Real").Cells(i,
17).value & Worksheets("Real").Cells(i, 62).value
Next i
For i = 2 To lngRow2
Worksheets("Analisa").Cells(i, 32).value = Worksheets("Analisa").Cells(i,
5).value & Worksheets("Analisa").Cells(i, 9).value
Next i
For i = 2 To lngRow3
Worksheets("OA").Cells(i, 59).value = Worksheets("OA").Cells(i, 4).value &
Worksheets("OA").Cells(i, 5).value
Next i
Sheets.Add.Name = "Raw"
'==========PASANG DATA========
Worksheets("Raw").Cells(1, 1).value = "Plant"
53).value
Worksheets("Raw").Cells(i, 9).value = (Worksheets("Raw").Cells(i,
7).value * Worksheets("Raw").Cells(i, 6).value) - Worksheets("Raw").Cells(i,
8).value
Handler:
'Worksheets("Main").Rows(i).Delete
Resume Handler2
Handler2:
Next i
'===========HAPUS YG KOSONG===========
' Input box to determine the total number of rows in the worksheet.
counter = Worksheets("Raw").Cells(65556, 1).End(xlUp).Row
ActiveCell.Select
' Loops through the desired number of rows.
For i = 1 To counter
' Checks to see if the active cell is blank.
If ActiveCell = vbNullString Then
Selection.EntireRow.Delete
End If
Next i
End Sub
Private Sub ComboBox1_Change()
Dim libro As Worksheet
Dim combo As ComboBox
Dim lngRows As Long
Dim rngMerge As Range, cell As Range
Dim lngRows2 As Long
Dim oRange As Excel.Range
Dim oTarget As Excel.Range
Dim oRow As Excel.Range
Dim oRowAmend As Excel.Range
Dim oDic As Scripting.Dictionary
Dim sIndex As String
Dim vKey As Variant
Dim vItem As Variant
Dim data As Variant
Dim a As Long
Dim countDict As Variant
Dim countDict2 As Variant
Dim countDict3 As Variant
Dim countDict4 As Variant
Dim countDictPivot As Variant
'Application.EnableEvents = True
choice = Me.ComboBox1.value
Select Case choice
'================================CHOICE
PLANT===================================
Case Is = "Plant"
Application.DisplayAlerts = False
'If .Text = "Plant" Then
Sheets.Add.Name = "Laporan Plant"
lngRows = Worksheets("Raw").Cells(65556, 1).End(xlUp).Row
For i = 1 To lngRows
'==============URUTKAN YG SETIPE=============
'Worksheets("Main").Cells(3).CurrentRegion.Sort
key1:=Worksheets("Raw").Cells(3), Header:=xlYes 'change this to xlYes if
your table has header cells
Worksheets("Laporan Plant").Cells(2).CurrentRegion.Sort
key1:=Worksheets("Laporan Plant").Cells(2), Header:=xlYes 'change this to
xlYes if your table has header cells
Worksheets("Laporan Plant").Cells(1).CurrentRegion.Sort
key1:=Worksheets("Laporan Plant").Cells(1), Header:=xlYes 'change this to
xlYes if your table has header cells
countDictUnit(category) = data(a, 2)
countDict(category) = value 'first time we find that category, create it
countDict2(category) = value2 'first time we find that category, create
it
countDict3(category) = value3 'first time we find that category, create
it
countDict4(category) = value4 'first time we find that category, create
it
End If
Next a
a=1
For Each d In countDict
data(a, 1) = countDictPivot(d)
data(a, 2) = countDictUnit(d)
data(a, 3) = countDict(d)
data(a, 4) = countDict2(d)
data(a, 5) = countDict3(d)
data(a, 6) = countDict4(d)
a=a+1
Next d
'Puts the result back in the sheet in column D/E, including headers
With ActiveSheet
.Range("K1").Resize(UBound(data, 1), UBound(data, 2)) = data
End With
.Range("K1:P1").value = .Range("A1:F1").value
.Columns("A:J").EntireColumn.Delete
End With
'===============MERGE AND CENTER PIVOT===========
Range("A1:F1").Interior.ColorIndex = 24
rngMerge.HorizontalAlignment = xlCenter
'rngMerge2.HorizontalAlignment = xlCenter
rngMerge.VerticalAlignment = xlCenter
'rngMerge2.VerticalAlignment = xlCenter
MergeAgainPlant:
GoTo MergeAgainPlant
End If
Next
Application.DisplayAlerts = True
'Application.ScreenUpdating = True
'===============================CHOICE
PROVINSI===============================
Case Is = "Provinsi"
Application.DisplayAlerts = False
'If .Text = "Provinsi" Then
Sheets.Add.Name = "Laporan Provinsi"
lngRows = Worksheets("Raw").Cells(65556, 1).End(xlUp).Row
For i = 1 To lngRows
'==============URUTKAN YG SETIPE=============
'Worksheets("Main").Cells(3).CurrentRegion.Sort
key1:=Worksheets("Raw").Cells(3), Header:=xlYes 'change this to xlYes if
your table has header cells
Worksheets("Laporan Provinsi").Cells(2).CurrentRegion.Sort
key1:=Worksheets("Laporan Provinsi").Cells(2), Header:=xlYes 'change this to
xlYes if your table has header cells
Worksheets("Laporan Provinsi").Cells(1).CurrentRegion.Sort
key1:=Worksheets("Laporan Provinsi").Cells(1), Header:=xlYes 'change this to
xlYes if your table has header cells
countDictUnit(category) = data(a, 2)
countDict(category) = value 'first time we find that category, create it
countDict2(category) = value2 'first time we find that category, create
it
countDict3(category) = value3 'first time we find that category, create
it
countDict4(category) = value4 'first time we find that category, create
it
End If
Next a
a=1
For Each d In countDict
data(a, 1) = countDictPivot(d)
data(a, 2) = countDictUnit(d)
data(a, 3) = countDict(d)
data(a, 4) = countDict2(d)
data(a, 5) = countDict3(d)
data(a, 6) = countDict4(d)
a=a+1
Next d
'Puts the result back in the sheet in column D/E, including headers
With ActiveSheet
.Range("K1").Resize(UBound(data, 1), UBound(data, 2)) = data
End With
.Range("K1:P1").value = .Range("A1:F1").value
.Columns("A:J").EntireColumn.Delete
End With
'===============MERGE AND CENTER PIVOT===========
Range("A1:F1").Interior.ColorIndex = 24
rngMerge.HorizontalAlignment = xlCenter
'rngMerge2.HorizontalAlignment = xlCenter
rngMerge.VerticalAlignment = xlCenter
'rngMerge2.VerticalAlignment = xlCenter
MergeAgainProvinsi:
GoTo MergeAgainProvinsi
End If
Next
Application.DisplayAlerts = True
'Application.ScreenUpdating = True
'Application.ScreenUpdating = True
End Select
End With
End Sub
Private Sub CommandButton1_Click()
Dim wb1 As Workbook
Dim wb2 As Workbook
FileToOpen = Application.GetOpenFilename _
(Title:="Please choose a Workbook to Parse", _
FileFilter:=myFilter)
End Sub