Convert 1-1 back to 1-1 from being converted to a date

ChrisMcIntyre

New Member
Joined
Jan 6, 2022
Messages
37
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Morning all, Happy Friday!!

A system I use spits out a document directly into Excel, but frustratingly some of the columns have numbers like 1-1 (one of one) or 3-9 (three of nine), and Excel is converting these numbers to dates.

Is there an easy way to convert these back to the original system numbers?

If there's no simple method of conversion that doesn't involve lots of retyping then, I would love to build something in VBA whereby the user clicks a button on a sheet, it prompts the user to choose the file to format and then it does all the formatting and then prompts to save.

Bottom line, I want the quickest solution possible please... And I know someone out there knows the pesky solution :)
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
If you're looking for a simple formula approach, something like this:
Excel Formula:
=DAY(A2)&" of "&MONTH(A2)
 
Upvote 0
Hi njimack, thanks so much for this, I made some tweaks as my machine is US date formatted (don't ask why :) ) and I changed OF to - so the info looks the same in the data column and the new column, it works great!

=MONTH(A1)&"-"&DAY(A1)

1644576346819.png
 
Upvote 0
Another option ..

22 02 11.xlsm
AB
11-Jan1-1
23-Jan1-3
39-Mar3-9
48-May5-8
Change from date
Cell Formulas
RangeFormula
B1:B4B1=TEXT(A1,"m-d")
 
Upvote 0
Thanks Peter!

Both work great, I just discovered that the final report can only show the result, so no extra columns and the result as text and not a formula, so I think I will need to create something in VBA that will create the extra columns get the results and paste them back over as values somehow, then remove the extra columns created by the VBA... Boy, what a pain.

Thanks both for the solutions!!
 
Upvote 0
Try something like this - no extra columns required. Test with a copy as it directly over-writes the original data.
May need to adjust the range.

VBA Code:
Sub ConvertBack()
  With Range("A1", Range("A" & Rows.Count).End(xlUp))
    .NumberFormat = "@"
    .Value = Evaluate("text(" & .Address & ",""m-d"")")
  End With
End Sub
 
Upvote 0
Solution
Bit cheeky, is it possible for you to help me with getting this macro into a standalone doc?

Ideally the user opens this new Excel doc, clicks the macro button, the macro pops up the file explorer search, the user chooses the DATA file to make the changes to, and the macro runs and updates all the numbers on the DATA sheet, the user then just then needs to save it.
 
Upvote 0
Also, sorry, the macro needs to ignore blank cells. Currently, when it comes across a blank cell in between the first and last entry, it's adding 1-0
 
Upvote 0
Try this. Code also saves the data workbook after making the changes.

VBA Code:
Sub ConvertBack_v2()
  Dim sFile As String
  Dim wbData As Workbook
  
  sFile = Application.GetOpenFilename()
  If sFile <> "False" Then
    Set wbData = Workbooks.Open(sFile)
    With wbData.Sheets("DATA")
      With .Range("A1", .Range("A" & Rows.Count).End(xlUp))
        .NumberFormat = "@"
        .Value = Evaluate(Replace("if(#="""","""",text(#,""m-d""))", "#", .Address))
      End With
    End With
    wbData.Save
  End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,878
Messages
6,122,062
Members
449,064
Latest member
scottdog129

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