103 lines
2.2 KiB
QBasic
103 lines
2.2 KiB
QBasic
Attribute VB_Name = "awp_xlsx_helloworld_pivot"
|
|
|
|
Option Explicit
|
|
|
|
' get the last row for a given xls sheet
|
|
Function getLastRow(ByVal start_row As Integer)
|
|
Dim last_row As Boolean
|
|
Dim last_check_row As Integer
|
|
Dim scan_row As Integer
|
|
Dim i As Integer
|
|
Dim cell_value_1 As String
|
|
|
|
|
|
Dim next_row_1 As Integer
|
|
|
|
scan_row = start_row
|
|
last_check_row = 9999
|
|
|
|
For i = start_row To last_check_row
|
|
scan_row = i
|
|
last_row = True
|
|
|
|
next_row_1 = i + 1
|
|
|
|
cell_value_1 = ReadCellValue("A" & CStr(next_row_1))
|
|
|
|
If (cell_value_1 <> "") Then
|
|
last_row = False
|
|
End If
|
|
|
|
If (last_row = True) Then
|
|
'Debug.Print "last row found"
|
|
Exit For
|
|
End If
|
|
Next i
|
|
|
|
getLastRow = scan_row
|
|
|
|
End Function
|
|
|
|
' get the value from cell for a given address
|
|
Function ReadCellValue(cell_addr As String)
|
|
|
|
ReadCellValue = Worksheets("Sheet1").Range(cell_addr).Value
|
|
|
|
End Function
|
|
|
|
' get the integer month from date
|
|
Function GetMonthFrDate(ByVal date_string As String) As Integer
|
|
Dim intMonth As Integer
|
|
Dim dt As String
|
|
dt = DateValue(date_string)
|
|
intMonth = month(dt)
|
|
GetMonthFrDate = intMonth
|
|
End Function
|
|
|
|
' get the integer quarter from date
|
|
Function GetQuarterFrDate(ByVal date_string As String) As Integer
|
|
Dim intQuarter As Integer
|
|
Dim intMonth As Integer
|
|
Dim dt As String
|
|
|
|
dt = DateValue(date_string)
|
|
intMonth = month(dt)
|
|
|
|
GetQuarterFrDate = Int((intMonth - 1) / 3) + 1
|
|
End Function
|
|
|
|
Function Run(ws As Worksheet)
|
|
Dim row_count As Integer
|
|
Dim rw As Variant
|
|
|
|
Run = Array(1, 2, 3, 4, 5, 6, 7, 8)
|
|
End Function
|
|
|
|
' canned method to open excel file
|
|
Function OpenFile(sPath As String)
|
|
Dim wb As Workbook
|
|
Set wb = Workbooks.Open(sPath)
|
|
wb.Windows(1).Visible = False
|
|
|
|
Dim count_figures_result As Variant
|
|
|
|
If Not (wb.Sheets("Sheet1") Is Nothing) Then
|
|
count_figures_result = awp_xlsx_helloworld_pivot.Run(wb.Sheets("Sheet1"))
|
|
End If
|
|
|
|
OpenFile = count_figures_result
|
|
|
|
wb.Close savechanges:=False
|
|
End Function
|
|
|
|
Sub Test()
|
|
awp_xlsx_helloworld_pivot.OpenFile ("c:\Temp\xlsx\Agent_Working_Performance.xlsx")
|
|
|
|
Debug.Print "done"
|
|
End Sub
|
|
|
|
Sub Helloworld()
|
|
Debug.Print "helloworld"
|
|
End Sub
|
|
|