Adding Rows to a Table 
Author Message
 Adding Rows to a Table

I have a table from which I have deleted all rows but the first. I would now
like to add rows using data I read from a txt file. My table has 6 columns,
and I will read data for each column from my input file. How can I do that?


Wed, 15 Oct 2003 10:16:34 GMT  
 Adding Rows to a Table

Maureen,

To add a single row to (the bottom of) a table, assuming it's been
declared as variable myTbl, you can use:

myTbl.Rows.Add

If you want to add several rows at a time, just loop that step.

To know how to fill the *columns* with data from your text file,
we'd need to know how that file is arranged.  Are you saying the
text file has lines like this:

  A, B, C, D
  E, F, G, H

but you want the cells in your table (after row 1) to look like
this?

  A  E
  B  F
  C  G
  D  H

It's almost certainly doable, but you need to explain more what you
want.  For starters, you'll probably need to do some file I/O, so
you could look at the help for the Open statement and the Input#
statement, for reading data from sequential access files.  (This
kind of thing dates back to old, icky, NON-Visual Basic and is a
lot less pretty than VBA.)  

In the most ultra-simple form, to read *one* item from a text file
("c:\test\myfile.txt") and put it in the first cell of the second
row of the table myTbl, you could use code like this:

Open "C:\m\myfile.txt" For Input As #1
Input #1, x
myTbl.Cell(2,1).Range.Text = x
Close #1

Hope this helps a little.


---------- WWW: http://www.speakeasy.org/~mtangard ----------------
----------- "Life is nothing if you aren't obsessed." --John Waters
-------------------------------------------------------------------

Quote:
> I have a table from which I have deleted all rows but the first. I would now
> like to add rows using data I read from a txt file. My table has 6 columns,
> and I will read data for each column from my input file. How can I do that?



Wed, 15 Oct 2003 20:02:18 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. to add row dynamically in table

2. trace new added rows of a table

3. adding a table row, without setting same defaults as previous row

4. row heights of table rows added by vba

5. How to Create 2 column table and continue adding rows

6. Format of Rows Added to a Table

7. add text to table rows

8. Running a macro to add a row in a table

9. Add row to the end of a table

10. Adding row to table is Slooooooow!

11. Adding new rows to related tables on a dataset

12. Help adding Table Rows dynamically Please!

 

 
Powered by phpBB® Forum Software