MJaspering
New Member
- Joined
- Oct 2, 2023
- Messages
- 8
- Office Version
- 365
- 2021
- Platform
- Windows
Hey All,
I am still pretty early in learning VBA and am wanting to build a reporting tool for my teams that help them to better understand their salary-to-revenue percentages. The general outline of what I am trying to build is as follows:
Any help is greatly appreciated - thank you!
I am still pretty early in learning VBA and am wanting to build a reporting tool for my teams that help them to better understand their salary-to-revenue percentages. The general outline of what I am trying to build is as follows:
- A table is exported to CSV from Workday.
- A teammate can then click on an ActiveX button that opens the File Explorer dialogue and allows them to select the CSV export.
- Once selected, the VBA sub would sum the numerical values from two specific columns in the CSV.
- These sum values would then be directed to specific cells on the worksheet.
Any help is greatly appreciated - thank you!
VBA Code:
Private Sub CommandButton1_Click()
Dim z As FileDialog
Dim zPath As String
Dim csv As String
Dim wsheet As String
Application.DisplayAlerts = False
Application.StatusBar = True
wsheet = ActiveWorkbook.Name
Set z = Application.FileDialog(msoFileDialogFilePicker)
z.Title = "File Selection:"
If z.Show = -1 Then
zPath = z.SelectedItems(1)
Else
Exit Sub
End If
If Right(zPath, 1) <> "\" Then Path = Path + "\"
csv = Dir(Path & "*.csv")
Do While csv <> ""
Application.StatusBar = "Converting: " & csv
Workbooks.Open Filename:=Path & csv
ActiveWorkbook.SaveAs Replace(Path & csv, ".csv", ".xlsx", vbTextCompare), _
xlWorkbookDefault
ActiveWorkbook.Close
Windows(wsheet).Activate
csv = Dir
Loop
Application.StatusBar = False
Application.DisplayAlerts = True
End Sub