How to export from excel to location in text file
Hi Folks, new to the forum.
I did a search and found some useful information, but nothing specifically related to what I'm trying to do. I'm also very new at VB, although I've got some proficiency from creating macros in Excel, clickEvent, etc.
I want to copy some specific data from a given cell in Excel and paste that data into a line of text in a text file.
For example, I want to find the cell that has the text 'some_thing_a', and copy a given cell in that row. In this example, that cell has the value: 3.7625. That value would then be copied to the following line in a text file, as shown by the bold text: some_thing_a=3.7625 //some number 'a'.
So my question is, in a nutshell, how do I copy data from an excel file to a specific string location in a text file?
Thanks in advance.
Re: How to export from excel to location in text file
Moved to Office Development
Re: How to export from excel to location in text file
you can use excel find method to find the string
then use the .offset to the value of the cell in that row like
myresult = Sheets("sheet1").UsedRange.Find("test").Offset(0, 2)
myresult contains the value of the cell 2 columns across in the same row as test set the appropriate range to search in
to write to an existing text file, you need to open the file for input, read the data into an array, close the file, loop through the array to find the appropriate line to edit, open the file again for output, print the array to file close the file