I'd like to create a VBA macro that replaces all cells in a worksheet with text strings in a time format (regular expression):
(1[0-2]|[1-9]):[0-5][0-9]:[0-5][0-9] [AP]M
with the cell address and worksheet name. I think the call will be akin too:
Cells.Replace What:="1:23:45 AM",
Replacement:="=cell(""filename"")&cell(""Address"")", _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:= _
False, ReplaceFormat:=False
But I'm hoping I can make the "What:=" argument a reg ex, or at least restricted to a time format.
How would I go about this?
Test Data: Save the following in CSV format:
00:00,04:27,00:36,04:31,00:00
00:00,00:00,04:18,01:07,10:06
00:00,00:00,00:00,00:00,00:00
Eventually the macro will delete all the zero times, and replace the other times with static text that is the evaluated formula =cell("filename")&"!"&cell("address")
Result of acting on the above input file (I would be saving the sheets as XLSX):
[ A ] [ B ] [ C ] [ D ] [ E ]
[1] 'Sheet1!$B$1 'Sheet1!$C$1 'Sheet1!$D$1
[2] 'Sheet1!$C$2 'Sheet1!$D$2 'Sheet1!$E$2
[3]
For brevity, I stripped out the directory and file name that the =cell("filename") function returns, although the above is what I really would like.
