I would like to create a VBA macro that replaces all cells in a worksheet with text strings in time format (regular expression):
(1[0-2]|[1-9]):[0-5][0-9]:[0-5][0-9] [AP]M
with cell address and sheet name. I think the call will be similar 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 hope I can make the What:= argument an reg ex argument, or at least a limited time format.
How can i do 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
In the end, the macro will delete all zero times and replace the other moments with static text, which is the estimated formula =cell("filename")&"!"&cell("address")
The result of the action on the above input file (I would save 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 deleted the directory and file name returned by =cell("filename") , although this is what I really need.