I am new to VBA. I wish to create a macro to do the following:
1. browse and choose the Excel file
Code: Select all
Dim EXL As Object
Dim xlsPath As String
Set EXL = CreateObject("Excel.Application")
xlsPath = BrowseForFile("Please choose an Excel file", True)
If Not xlsPath = vbNullString Then
Private Function BrowseForFile(Optional strTitle As String, Optional bExcel As Boolean) As String
Dim fDialog As FileDialog
On Error GoTo ERR_HANDLER
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
.Title = strTitle
.AllowMultiSelect = False
.Filters.Clear
If bExcel Then
.Filters.add "Excel workbooks", "*.xls,*.xlsx,*.xlsm"
Else
.Filters.add "Word documents", "*.doc,*.docx,*.docm"
End If
.InitialView = msoFileDialogViewList
If .Show <> -1 Then GoTo ERR_HANDLER:
BrowseForFile = fDialog.SelectedItems.Item(1)
End With
lbl_Exit:
Exit Function
ERR_HANDLER:
BrowseForFile = vbNullString
Resume lbl_Exit
End Function
for example:
000345
000458
000756
3. macro calculates start time from the extracted 6-digit numbers
For example, the 6-digit number in Excel are as follows:
000345
000458
000756
then the start Time (seconds as unit) is equal to =
00*3600 +3*60 +45 =225
00*3600 + 4*60+58 =298
00*3600 + 7*60+56 = 476
Code: Select all
Dim Hr As Integer
Dim Mn As Integer
Dim Sc As Integer
Dim startTime As Long
Do While .Execute
' Get hours, minutes, and seconds from time marker
hrs = CInt(Left(aRng.Text, 2))
mins = CInt(Mid(aRng.Text, 3, 2))
secs = CInt(Right(aRng.Text, 2))
startTime = hrs * 3600 + mins * 60 + secs
original hyperlinks are like:
https://xxxxxxx.xxxxx.xxx/xxxxxx/?meeti ... t=Time%201
https://xxxxxxx.xxxxx.xxx/xxxxxx/?meeti ... t=Time%202
https://xxxxxxx.xxxxx.xxx/xxxxxx/?meeti ... t=Time%203
Replace as:
https://xxxxxxx.xxxxx.xxx/xxxxxx/?meeti ... &start=225
https://xxxxxxx.xxxxx.xxx/xxxxxx/?meeti ... &start=298
https://xxxxxxx.xxxxx.xxx/xxxxxx/?meeti ... &start=476
I would like to express my gratitude in advance to anyone who can provide assistance in editing the macro. Thank you!