I want a VBA codes that will do the following; When I click on C2 of the Active…
- User
I want a VBA codes that will do the following; When I click on C2 of the Active worksheet, PopUp a Yes or No message that asks the following, "This process will copy all existing completed Tasks to the the next Uncompleted Task" Line break in the Popup "and paste the copy into workbook 'Service Providers History'." Double Line break in the Popup "After the paste, all copied Tasks will be deleted." Line break in the Popup "Would you like to continue?" Double Line break in the Popup "This process takes about 60 seconds" If 'No' is selected the exit the sub. If 'Yes' is selected then run Module called 'ServiceProvidersHistory'
- Assistant
Here's the VBA code that accomplishes the task you described:
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$C$2" Then Dim response As Integer response = MsgBox("This process will copy all existing completed Tasks to the next Uncompleted Task" & vbCrLf & _ "and paste the copy into workbook 'Service Providers History'." & vbCrLf & _ "After the paste, all copied Tasks will be deleted." & vbCrLf & vbCrLf & _ "Would you like to continue?" & vbCrLf & vbCrLf & _ "This process takes about 60 seconds", vbQuestion + vbYesNo, "Confirmation") If response = vbYes Then ' Call the module "ServiceProvidersHistory" ServiceProvidersHistory End If End If End SubThis code should be placed in the code module of the desired worksheet. It uses the
Worksheet_SelectionChangeevent, which occurs when the selection is changed on the worksheet. When cell C2 is selected, the code displays a message box with the desired message. If the user selects "Yes," the module is called. If the user selects "No," the code doesn't do anything further.