kenchristensen11
Board Regular
- Joined
- Oct 12, 2016
- Messages
- 52
Hello,
I have the below code and after the macro is completed (e.g., after the "Archive" button is clicked and the macro runs), I would to play an .mp3 file from file location, but I haven't had any luck.
Is there any way this can be done? Thanks!!
I have the below code and after the macro is completed (e.g., after the "Archive" button is clicked and the macro runs), I would to play an .mp3 file from file location, but I haven't had any luck.
Is there any way this can be done? Thanks!!
VBA Code:
Sub FileAway()
Dim PssWrd
Dim sourceSheet As Worksheet
Dim targetSheet As Worksheet
Dim lastRow As Long
Dim i As Long
PssWrd = Application.InputBox(Prompt:="Are you Tim or Kevin?")
If PssWrd <> "RESIDUALS" Then
Exit Sub
Else
' Set the source and target sheets
Set sourceSheet = ThisWorkbook.Worksheets("All Quarters")
Set targetSheet = ThisWorkbook.Worksheets("Archive")
' Find the last row in the source sheet
lastRow = sourceSheet.Cells(sourceSheet.Rows.Count, "B").End(xlUp).Row
' Loop through each row in the source sheet
For i = 9 To lastRow
' Check if cell in column B contains "Archive"
If sourceSheet.Cells(i, "B").Value = "Archive" Then
' Copy the entire row to the target sheet
sourceSheet.Rows(i).Copy Destination:=targetSheet.Cells(targetSheet.Rows.Count, "A").End(xlUp).Offset(1)
' Delete the row from the source sheet
sourceSheet.Rows(i).Delete
' Decrement the loop counter as the rows are shifting up
i = i - 1
' Update the last row value
lastRow = lastRow - 1
End If
Next i
End If
End Sub