View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
joel[_970_] joel[_970_] is offline
external usenet poster
 
Posts: 1
Default Get column name and data type from closed workbook


The column headers are in Row 1 of each table. Using ADO method
indexing starts at zero so you are lokking at row 0.

For Each tbl In cat.Tables
szTableName = tbl.Name
''' Worksheet names always end in the "$" character.
If Right$(szTableName, 1) = "$" Then
Sheets("data").Cells(lRow, "B").Value = _
Left$(szTableName, Len(szTableName) - 1)
Set HeaderRow = tbl.Rows(0)
ColCount = 3
for each col in HeaderRow.Cells
Sheets("data").Cells(lRow, ColCount).Value = col
ColCount = ColCount + 1
next col
lRow = lRow + 1
End If
Next tbl


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=200033

http://www.thecodecage.com/forumz