zookeepertx
Well-known Member
- Joined
- May 27, 2011
- Messages
- 586
- Office Version
- 365
- Platform
- Windows
Hello all,
I have spent 2 days trying to get this to work right and I'm obviously leaving out a parenthesis or a comma or something.
So, I'm trying with VBA to extract just the date from the following text:
I don't want the spaces before or after the date and whether the month and day are 1 or 2 characters, it needs to show the whole date. (I don't want a formula in the report, I just want the date to appear in F2 (or whatever row is the current destination row).
My thinking was to use MID. Establish the cell being evaluated, find the first character after the : - which would be 9 in this case - to use as the start character. Then - to find the length of the result I need - find the first space after the: and subtract it from the length of text in the cell.
Here's what I've arrived at at this point but it's not working:
But I keep getting a "Compile error: Expected )" message.
Can someone enlighten me as to what I'm leaving out or have in there that I don't need?
I would be very grateful; I'm so tired of looking at this I could tear my hair out!
Jenny
I have spent 2 days trying to get this to work right and I'm obviously leaving out a parenthesis or a comma or something.
So, I'm trying with VBA to extract just the date from the following text:
Date created: 9/24/2024 2:35:55 PM |
I don't want the spaces before or after the date and whether the month and day are 1 or 2 characters, it needs to show the whole date. (I don't want a formula in the report, I just want the date to appear in F2 (or whatever row is the current destination row).
My thinking was to use MID. Establish the cell being evaluated, find the first character after the : - which would be 9 in this case - to use as the start character. Then - to find the length of the result I need - find the first space after the: and subtract it from the length of text in the cell.
Here's what I've arrived at at this point but it's not working:
VBA Code:
Mid(Cells(i, 1), (InStr(Cells(i, 1), ":") +2), (Len(Cells(i, 1) ) -((InStr(Cells(i,1), " " ) , (InStr(Cells(i, 1), ":") +2)-1) )))
But I keep getting a "Compile error: Expected )" message.
Can someone enlighten me as to what I'm leaving out or have in there that I don't need?
I would be very grateful; I'm so tired of looking at this I could tear my hair out!
Jenny