|
-
Oct 30th, 2008, 08:49 AM
#1
Thread Starter
New Member
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.
-
Oct 30th, 2008, 09:37 AM
#2
Re: How to export from excel to location in text file
Moved to Office Development
-
Oct 30th, 2008, 03:39 PM
#3
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|