I have a VBA code that requires the use of an input text file. This text file consists of multiple arrays filled with values used by another program. The values of the text file are hardcoded at the moment, as well as some cells' values from the spreadsheet where the button with the macro attached to it. My code looks like this:
Public Sub CreateInputFile()
Dim sInFile As String
sInFile = Application.ActiveWorkbook.Path & "\StrInput.txt"
Call KillIfExists(sInFile)
Dim FN As Integer
FN = FreeFile ' get a file number
Open sInFile For Output As FN
Print #FN, "Version2.18" ' Version Number
Print #FN, "Title" ' Title
Print #FN, "13500 " & Range("A1").Value & " 0.0 0.0 1.0 514.97 0.984 0.983 0.978 0.961 51760 0.0 1 0.0 1 1 " 'A Vector goes here
This works, yet I am not sure how to code it so that the Range("A1").Value is in the beginning or how to use Range("B3").Value a the end. Also, if I wanted to have two next to eachother, maybe something like the following would work to maintain the 'number (space) number (space)...' format as shown above:
Print #FN, "Range("A1").Value & Range("BD35").Value & " 1.0 " & Range("S9").Value & Range("J7").Value"
Finally, I was wondering how I could also write the value from a cell from a different spreadsheet (ie, not the one that has the button with this macro attached). I was thinking something like the following, but I get an error:
Print #FN, "Sheets("Sheet 2").Range("A1").Value & Range("BD35").Value & " 1.0 " & Range("S9").Value & Sheets("Sheet 4").Range("J7").Value"
Thanks!
Bookmarks