Pop Up Window/Message

DharmeshChauhan

New Member
Joined
Apr 25, 2022
Messages
16
Office Version
  1. 365
Platform
  1. Windows
Hi

I currently have a spreadsheet whereby clients are entering date of births as 12.02.2022 or 12/02/2022

I require this information to be in this format 12-02-2022, is there a way of automatically converting this once the client has entered the DOB and moved on to the next cell, or can a warning/pop up message be displayed every time they click on the cell that would inform them to enter the DOB in a certain way

Thanks In Advance

Dharm
 
Try:
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    If Target.Column <> 4 Then Exit Sub
    Dim strDate As String
    Do
        strDate = InputBox("Please enter date of birth in date format: dd-mm-yyyy", "Date Of Birth", Format("dd-mm-yyyy"))
        If strDate <> "" Then
            If IsDate(strDate) Then
                Target = Format(CDate(strDate), "dd-mm-yyyy")
                Target.Offset(, 1).Select
                Exit Do
            Else
                MsgBox "Wrong date format"
                Target.ClearContents
            End If
        ElseIf strDate = "" Then
            MsgBox "You must enter a date.", vbOKOnly, ""
        End If
    Loop
End Sub
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Try:
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    If Target.Column <> 4 Then Exit Sub
    Dim strDate As String
    Do
        strDate = InputBox("Please enter date of birth in date format: dd-mm-yyyy", "Date Of Birth", Format("dd-mm-yyyy"))
        If strDate <> "" Then
            If IsDate(strDate) Then
                Target = Format(CDate(strDate), "dd-mm-yyyy")
                Target.Offset(, 1).Select
                Exit Do
            Else
                MsgBox "Wrong date format"
                Target.ClearContents
            End If
        ElseIf strDate = "" Then
            MsgBox "You must enter a date.", vbOKOnly, ""
        End If
    Loop
End Sub
Hi

Thanks again

I noticed that if a correct format date is entered in the cell and you were tabbing (or using the arrowing keys) to move across the row it pops up with the messaged to entered the date, is there a way whereby if the correct date is in the correct format is entered that the pop wont come up, allowing the client to tab (with the tab button or arrow buttons) through each cell in that row
 
Upvote 0
Try:
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    If Target.Column <> 4 Then Exit Sub
    Dim strDate As String
    If Target = "" Then
        Do
            strDate = InputBox("Please enter date of birth in date format: dd-mm-yyyy", "Date Of Birth", Format("dd-mm-yyyy"))
            If strDate <> "" Then
                If IsDate(strDate) Then
                    Target = Format(CDate(strDate), "dd-mm-yyyy")
                    Target.Offset(, 1).Select
                    Exit Do
                Else
                    MsgBox "Wrong date format"
                    Target.ClearContents
                End If
            ElseIf strDate = "" Then
                MsgBox "You must enter a date.", vbOKOnly, ""
            End If
        Loop
    End If
End Sub
 
Last edited:
Upvote 0
Try:
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    If Target.Column <> 4 Then Exit Sub
    Dim strDate As String
    If Target = "" Then
        Do
            strDate = InputBox("Please enter date of birth in date format: dd-mm-yyyy", "Date Of Birth", Format("dd-mm-yyyy"))
            If strDate <> "" Then
                If IsDate(strDate) Then
                    Target = Format(CDate(strDate), "dd-mm-yyyy")
                    Target.Offset(, 1).Select
                    Exit Do
                Else
                    MsgBox "Wrong date format"
                    Target.ClearContents
                End If
            ElseIf strDate = "" Then
                MsgBox "You must enter a date.", vbOKOnly, ""
            End If
        Loop
    End If
End Sub
Hi really appreciate this, thanks again for your time on this

The blank spreadsheet is sent over to the clients to fill out, I have just been told that some times the client may copy the data cross from another spreadsheet instead of manually inputting all the data. is there a way of the above coding recognising this and still converting the data in the format I require?

Some (very few) client sometimes using Vlookup's to transfer the data on to my spreadsheet is there a way of the above coding recognising this and still converting the data in the format I require?

Thanks In Advance
 
Upvote 0
Unfortunately, I don't think that copy/paste and using formulas will work because of how the macros are triggered.
 
Upvote 0
Unfortunately, I don't think that copy/paste and using formulas will work because of how the macros are triggered.
oh ok, if they were to copy data (by paste values) from another spreadsheet would the macro be able to format in the way we require?
 
Upvote 0
No, the copy/paste will not trigger the macros. They can copy paste the entire row or rows of data but they would have to enter the DOB and phone number manually.
 
Upvote 0
No, the copy/paste will not trigger the macros. They can copy paste the entire row or rows of data but they would have to enter the DOB and phone number manually.
Hi

I thought this would be the case.

If a client was good with excel (very rare), then I think I would send him a blank copy without the macros so that they could copy/paste or use a Vlookup to get the data into my spreadsheet, and then they email me over the completed spreadsheet

Could I insert a new column next to each of the DOB/Phone number and use a formula to copy the data and format it in the way I require? and then paste value or delete their data? if so what would the formula would I need to do this for both DOB and phone number
 
Last edited:
Upvote 0
Could I insert a new column next to each of the DOB/Phone number and use a formula to copy the data and format it in the way I require? and then paste value or delete their data?
I'm sorry but I don't understand what you mean. Please explain in detail using a few examples.
 
Upvote 0
I'm sorry but I don't understand what you mean. Please explain in detail using a few examples.

If a client was sent a blank copy of the spreadsheet (without the macros) so that they could copy/paste or use a Vlookup to get their data into my spreadsheet

See picture1.png


Would I be able to insert a new column next to column D, then paste a formula into the new inserted column so that the formula would look at the text/data in the DOB “column D” and convert it into the format I needed, once its converted I would then delete column D

See picture2.png


I would do the same for the phone number column

I hope this explains it better

CECG Individual Exposure Form (QF 104) V2 - Dharmesh Macro.xlsm
ABCDEF
1Colleague/Employee IDSurnameForenameDOBColumn1Employee email address
21001BloggsJoe01.02.2022
3
4
Full list
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A1:A4,F1:G4Cell ValueduplicatestextNO
A1:E1Cell ValueduplicatestextNO
A1:E1Cell Value="NoMatch"textNO
 

Attachments

  • Picture1.png
    Picture1.png
    9.1 KB · Views: 4
  • Picture2.png
    Picture2.png
    37.9 KB · Views: 4
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,154
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top