vba help - extract date from text file

Mallesh23

Well-known Member
Joined
Feb 4, 2009
Messages
976
Office Version
  1. 2010
Platform
  1. Windows
Hi Team,

How to extract dates (05May2021) from text file

FilePath = ThisWorkbook.Path & "\041 - Data.txt"

Constant word Reconcilation , date comes after that , date my varies.

--------Data------
Google 001 Reconcilation (offline) 05May2020 7:10 page 1 --------------- this lines is from Notepad tx.
Google 101 Reconcilation (offline) 05Jun2021 7:10 page 4


Thanks
mg
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hi,​
you can use the Split VBA text function …​
 
Upvote 0
Hi Mark,
after splitting I need to check whether splitted value is date, how to check that



Thanks
mg
 
Upvote 0
Can you show us a little larger sample size, showing different variations in the data?
Will every record have the phrase "Reconciliation (offline)" before the date?
 
Upvote 0
Hi Joe,

Reconciliation (offline) is a standard word, always appear on first line of text file, No loop Required.
Google 001 Reconcilation (offline) 05May2020 7:10 page 1

What I am thinking
trim the string ,
split the text,
Check length = 9,
and check mid month Name (Jan-Dec)


Thanks
mg
 
Upvote 0
See if this gets you started.
This should pull the date portion of that string out of it.
VBA Code:
Sub MySplit()

    Dim str As String
    Dim arr() As String
    Dim dte As String

'   Specify string to split
    str = Range("A1")

'   Split string
    arr = Split(str, " ")
   
'   Get value from 5th word
    dte = arr(4)
   
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,731
Members
448,987
Latest member
marion_davis

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