Private Sub wkscmd_ExtractData_Click()
Call ExtractDataX_Click
Call ExtractDataY_Click
Sheets("Sheet1").Select
Sheets("Sheet1").Copy
Application.DisplayAlerts = False
ActiveSheet.Name = "DailyReportData"
ActiveWorkbook.SaveAs ThisWorkbook.PATH & "\Summary&AggregateMetrics-To-Date" '& Format(Date, "mmmyy")
Application.DisplayAlerts = True
Windows("DailyRpt-Import&ExtractMacro.xls").Activate 'Go back to rawdata workbook
ActiveWorkbook.Close SaveChanges:=False
End Sub
Private Sub ExtractDataX_Click()
' Local Variables
Dim cell As Range, rngOut As Range
Dim strDate As String, strTable As String
Dim strPreAGG As String, strPostAGG As String, strCompression As String
Dim strRenovated As String, strRenopercent As String
' Read data
For Each cell In Me.Range("rdi_TableTop", "A" & Me.Range("A65536").End(xlUp).Row)
If ActiveSheet.Name = Me.Name Then cell.Select
' Get effective date
If InStr(cell, "SUMMARY METRICS:") > 0 Then
If strDate = "" Or strDate <> Right(cell, 10) Then strDate = Right(cell, 10)
strDate = Format(strDate, "mm/dd/yyyy")
End If
' Get Global House Count:
If InStr(cell, "GLOBAL HOUSE COUNT:") > 0 Then
'If strPreAGG = "" Or strPreAGG <> Trim(Mid(cell, 22, 13)) Then
strPreAGG = Trim(Mid(cell, 22, 13))
strPostAGG = Trim(Mid(cell, 59, 11))
strCompression = Trim(Right(cell, 4))
strRenovated = Trim(Mid(cell, 38, 12))
strRenopercent = Trim(Mid(cell, 53, 4))
If InStr(cell, "TOTAL") = 0 Then
cell.Select
If IsNumeric(strPreAGG) And IsNumeric(strPostAGG) Then
Set rngOut = Worksheets("Sheet1").Range("A65536").End(xlUp).Offset(1, 0)
rngOut.Offset(0, 0) = strDate
rngOut.Offset(0, 1) = strPreAGG
rngOut.Offset(0, 2) = strPostAGG
rngOut.Offset(0, 3) = strCompression
rngOut.Offset(0, 4) = strRenovated
rngOut.Offset(0, 5) = strRenopercent
End If
End If
End If
Next cell
End Sub
Private Sub ExtractDataY_Click()
' Local Variables
Dim cell As Range, rngOut As Range
Dim strDate As String, strTable As String
Dim strPreAGG As String, strPostAGG As String, strCompression As String
Dim strRenovated As String, strRenopercent As String
' Read data
For Each cell In Me.Range("rdi_TableTop", "A" & Me.Range("A65536").End(xlUp).Row)
If ActiveSheet.Name = Me.Name Then cell.Select
' Get effective date
If InStr(cell, "AGGREGATION METRICS:") > 0 Then
If strDate = "" Or strDate <> Right(cell, 10) Then strDate = Right(cell, 10)
strDate = Format(strDate, "mm/dd/yyyy")
End If
' Get Global House Count:
If InStr(cell, "GLOBAL HOUSE COUNT:") > 0 Then
'If strPreAGG = "" Or strPreAGG <> Trim(Mid(cell, 22, 13)) Then
strPreAGG = Trim(Mid(cell, 24, 13))
strPostAGG = Trim(Mid(cell, 41, 16))
strCompression = Trim(Right(cell, 4))
If InStr(cell, "TOTAL") = 0 Then
cell.Select
If IsNumeric(strPreAGG) And IsNumeric(strPostAGG) Then
Set rngOut = Worksheets("Sheet1").Range("A65536").End(xlUp).Offset(0, -ActiveCell.Column + 1)
rngOut.Offset(0, 0) = strDate
rngOut.Offset(0, 1) = strPreAGG
rngOut.Offset(0, 2) = strPostAGG
rngOut.Offset(0, 3) = strCompression
End If
End If
End If
Next cell
End Sub
Thanks for taking the time to read my post.
Bookmarks