Date and Text in one field

hatstand

Well-known Member
Joined
Mar 17, 2005
Messages
778
Office Version
  1. 2016
Platform
  1. Windows
Hi All,

I have a folder of files imported into a query, unfortunately one of the fields is a Date field that has text, namely 'YTD'. So the field is converting to 'Any'. Converting this into Dates obviously gives errors, but I can't fathom out how to hold both Text and Dates in one field. Any ideas?
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
How are you importing the data and what is the format of the imported YTD field date?

After importing you could use the formula =mid(A1,4,len(A1)) This assumes that the date with YTD is in A1 and has a space after YTD
Copy the formula for each row that has the YTD date

Then select the calculated values copy and paste specials, as values only back over the cells with YTD

Alternatively do a search and replace

Press ctrl-H
Search for YTD replace leave blank

If you are using VBA to import the data then you can strip off the YTD either on the fly,or at the end using the following algorithm
VBA Code:
for each cell in range
     cell.text = mid(cell.text,4,len(cell.text))
next
range.numberformat = "dd/mm/yyyy" ' or whatever format you need the date.
 
Upvote 0
My apologies, I should have said I'm actually using Power Query to import. A handy solution that I'll keep though, Thanks.
 
Upvote 0

Forum statistics

Threads
1,223,805
Messages
6,174,722
Members
452,577
Latest member
Filipzgela

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