![]() |
Creating .txt files based on cell contents
I currently have a list of names and want to create a notes file for each
that I can hyperlink to. The hyper linking is fine. However I have over 300 files I need to create. Any suggestions would be gratefully accepted Many Thanks |
Creating .txt files based on cell contents
Mat,
Right click your sheet tab, view code and paste the code below in. Change MyPath to the directory you want the text files in. It will read down column A and for every name it will create a text file using that name(If it doesn't already exist) and create a hyperlink to it. Sub Lime() lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row MyPath = "C:\" Set MyRange = Range("A1:A" & lastrow) For Each c In MyRange Fname = MyPath & c.Value & ".txt" If Dir(Fname, vbNormal) = "" Then Open Fname For Output As #1 Close #1 ActiveSheet.Hyperlinks.Add Anchor:=c, Address:=MyPath & c.Value & ".txt" End If Next End Sub Mike "Matt Bennette" wrote: I currently have a list of names and want to create a notes file for each that I can hyperlink to. The hyper linking is fine. However I have over 300 files I need to create. Any suggestions would be gratefully accepted Many Thanks |
Creating .txt files based on cell contents
Thanks dude that worked a treat. !!! Genius
"Mike H" wrote: Mat, Right click your sheet tab, view code and paste the code below in. Change MyPath to the directory you want the text files in. It will read down column A and for every name it will create a text file using that name(If it doesn't already exist) and create a hyperlink to it. Sub Lime() lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row MyPath = "C:\" Set MyRange = Range("A1:A" & lastrow) For Each c In MyRange Fname = MyPath & c.Value & ".txt" If Dir(Fname, vbNormal) = "" Then Open Fname For Output As #1 Close #1 ActiveSheet.Hyperlinks.Add Anchor:=c, Address:=MyPath & c.Value & ".txt" End If Next End Sub Mike "Matt Bennette" wrote: I currently have a list of names and want to create a notes file for each that I can hyperlink to. The hyper linking is fine. However I have over 300 files I need to create. Any suggestions would be gratefully accepted Many Thanks |
Creating .txt files based on cell contents
Glad I could help
"Matt Bennette" wrote: Thanks dude that worked a treat. !!! Genius "Mike H" wrote: Mat, Right click your sheet tab, view code and paste the code below in. Change MyPath to the directory you want the text files in. It will read down column A and for every name it will create a text file using that name(If it doesn't already exist) and create a hyperlink to it. Sub Lime() lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row MyPath = "C:\" Set MyRange = Range("A1:A" & lastrow) For Each c In MyRange Fname = MyPath & c.Value & ".txt" If Dir(Fname, vbNormal) = "" Then Open Fname For Output As #1 Close #1 ActiveSheet.Hyperlinks.Add Anchor:=c, Address:=MyPath & c.Value & ".txt" End If Next End Sub Mike "Matt Bennette" wrote: I currently have a list of names and want to create a notes file for each that I can hyperlink to. The hyper linking is fine. However I have over 300 files I need to create. Any suggestions would be gratefully accepted Many Thanks |
Creating .txt files based on cell contents
If I might impose on your genius once more.
I have been trying to extract email addresses from word documents, about 1000. Ideally the result would produce a list of filenames in column A and the email address extracted from that file in column B. Usually, there would only be 1 email address per file. Again Many thanks "Mike H" wrote: Glad I could help "Matt Bennette" wrote: Thanks dude that worked a treat. !!! Genius "Mike H" wrote: Mat, Right click your sheet tab, view code and paste the code below in. Change MyPath to the directory you want the text files in. It will read down column A and for every name it will create a text file using that name(If it doesn't already exist) and create a hyperlink to it. Sub Lime() lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row MyPath = "C:\" Set MyRange = Range("A1:A" & lastrow) For Each c In MyRange Fname = MyPath & c.Value & ".txt" If Dir(Fname, vbNormal) = "" Then Open Fname For Output As #1 Close #1 ActiveSheet.Hyperlinks.Add Anchor:=c, Address:=MyPath & c.Value & ".txt" End If Next End Sub Mike "Matt Bennette" wrote: I currently have a list of names and want to create a notes file for each that I can hyperlink to. The hyper linking is fine. However I have over 300 files I need to create. Any suggestions would be gratefully accepted Many Thanks |
All times are GMT +1. The time now is 09:54 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com