Share via

Excel & Forms - Automatically Add Space between Time & AM/PM

Anonymous
2021-01-18T02:54:38+00:00

Hello,

I have a Microsoft Form setup.  Since Forms does not provide a simple time field, I have a text field.

As a side note, I also have a SharePoint Site setup with a direct link to the corresponding spreadsheet which discloses all of the responses to the form.

Now despite indicating the specific format that the time should be typed as, in the event the an individual enters "12:00PM" instead of "12:00 PM", is there a way for the Excel spreadsheet to automatically add this space between the time and the AM/PM.  If the space is not present, this affects the functionality of the formulas I created that are associated with this times.

Please let me know if I need to clarify or provide additional information.

Thanks!

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2021-01-20T05:55:44+00:00

try

=VALUE(IF(ISNUMBER(SEARCH(" ",A1)),A1,IF(ISNUMBER(SEARCH("AM",A1)),SUBSTITUTE(UPPER(A1),"AM"," AM"),SUBSTITUTE(UPPER(A1),"PM"," PM"))))

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

7 additional answers

Sort by: Most helpful
  1. Anonymous
    2021-01-19T15:39:58+00:00

    Good Morning,

    Any solution to address the time value being shown as a decimal? (noted above)

    Thanks,

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2021-01-18T20:03:34+00:00

    Good Afternoon,

    This solution would work.  However, if the time was input correctly (with a space - "12:00 PM") the formula changes the time value to a decimal instead of repeating the identical time.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2021-01-18T11:22:24+00:00

    Hi ChristopherToth1,

    According to your description, we got your concern about two issues.

    One is user input formats are not uniform. The other is you want to the Excel automatically add the space between the time and the AM/PM automatically. If we misunderstand, please correct us.

    So, first we suggest you notify users the format you want in the form to reduce the error format.

    And in spreadsheet, please try use the formula to meet your needs. The following step may help you.

    1.Open the spreadsheet and type 12:00PM.

    1. Select the cell B1.
    2. Enter the formula in the formula bar: =IF(ISNUMBER(SEARCH(" ",A1)),A1,IF(ISNUMBER(SEARCH("AM",A1)),SUBSTITUTE(A1,"AM"," AM"),SUBSTITUTE(A1,"PM"," PM")))

    I hope this information is useful to you. Have a good day.

    Best regards

    Tin

    Was this answer helpful?

    0 comments No comments
  4. OssieMac 48,001 Reputation points Volunteer Moderator
    2021-01-18T11:07:37+00:00

    This is not an answer that totally removes the problem. Only how to rectify the entries.

    Suggest that you make a backup of your workbook before testing the following in case it does not do what is expected.

    Not using a space between the numeric and the AM or PM causes the entry to become a text entry instead of a recognized time. This is a problem that has been around for ever.

    If the times are all in a specific column you can usually select the column and using Replace insert PM in the "Find what" field and space and PM in the "Replace with field". Repeat for AM.

    One would think that this method would change times that had been correctly entered with the one space to 2 spaces but fortunately it does not. Even if you enter a time with multiple spaces, Excel reduces the multiple spaces to one space.

    Was this answer helpful?

    0 comments No comments