March 13th, 2012, 07:04 AM
Comm Automation MS Excel
I am currently undertaking a small project to reformat fixed with data into ms excel.
I am currently able to read a text file to the end and output a string of data into an array, and thereafter insert this data logically into a column with ms excel.
I am having an issue when recreating this onto columns using different substring, each record read is skipped by one?
How can i also do this more effectively as i have like 30 other files with +/- 70 substring instances that i need to segment out in ms excel.
See below code :
Do While objSFR.Peek <> -1
writestring = objSFR.ReadLine.Substring(0, 17)
cellno = cellno + 1
cellnm = "A"
cellnm = cellnm + cellno.ToString()
cellnm = cellnm.Replace(" ", "").ToString().Trim()
oSheet.Range(cellnm.ToString().Trim()).Value = writestring
writestringb = objSFR.ReadLine.Substring(18, 3)
cellnob = cellnob + 1
cellnm1 = "B"
cellnm1 = cellnm1 + cellnob.ToString()
cellnm1 = cellnm1.Replace(" ", "").ToString().Trim()
oSheet.Range(cellnm1.ToString().Trim()).Value = writestringb
Let me know if you need me to paste the full code, the above is just logic i am try to use to segment each column based on substring value.
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!