how to insert some rows to existing excel file?
I searched the forum, and only found some examples of creating new excel files. How can I insert some rows to existing excel file by using VB6?
I have an excel file already which includes some sheets. In 2 sheets, I need insert some rows (with data in cells), so that the excel will compute some data based on the value in these cells.
I need do this in VB6.
thanks
Re: how to insert some rows to existing excel file?
Just open the file as you normally would with VB and then do somthing like this:
' select the sheet where you want to insert rows
Sheets("Sheet2").Select
' select the spot where you want to insert the row (3 are inserted here)
Range("A2:A4").Select
' insert the rows
Selection.EntireRow.Insert
Then just do a normal file read to get your data and add it to the rows/cells you just inserted.
Range("A2").Value = data from your file
Range("A3").Value = data from your file
Range("A4").Value = data from your file
Re: how to insert some rows to existing excel file?
Can you please let me know how I could open an excel file and then do the insert. I am a beginner, please give me an example which will help me do that. I have a file and would like to insert some rows after every line.
Please help me asap!!!