VBA for saving a cell into a text file

GermanKiwi

New member
Joined
Sep 27, 2018
Messages
3
Reaction score
0
Points
0
Excel Version(s)
Office 365 MSo
Hi there,

I,m new to the Forum and I'm sure that has been asked before but somehow I just cannot find the right answer. I'm after some VBA code that can save me one cell and one cell only with a file name held in a second cell.

Ok, lets explain that a bit better.
- I have a concatenate formula in cell A1 that collects Data from all over the spread sheet and puts it into the right order that is later on needed in the text file
---------- reason for doing that is because some values a separated by "," and others by ";"
- I then use VBA to copy and past A1 cell values only into cell A2
- Cell A3 is holding my filename which will change for every text file I create

What the code needs to do is to copy the text string in cell A2 into notepad and safe it with the filename in cell A3 into my HDD folder C:\personal\

The file needs to be an identical copy of the text string in cell A2 and will be used to automate a CNC production. A .csv file would work too as long as the text string is identical.

So far I only have found an option to save the whole workbook but that is not what I want.

Any help would be much appreciated. Thanks
 
Last edited:
.
Give this a try :

Code:
Sub textSave2()
Dim output As String


output = Sheets("Sheet1").Range("A2").Value
Open "C:\Personal" & "\" & Sheets("Sheet1").Range("A3").Value + ".txt" For Output As #1


Print #1, output


Close


End Sub
 
Thanks Logit, will give it a go later on today.
 
Thanks Logit that’s awesome. Its simple and works and just what I wanted. Thanks heaps
 
.
You are welcome.
 
Back
Top