G
Greg Maxey
For some practice with Word, I created a very simple spreadsheet that
contained a 3 x 3 cell range that I named "mySSrange"
In the cells I entered:
Cat Dog Hampster
Cow Pig Sheep
Wolf Badger Bear
When I run this code the first message displayed is "Cow." It seems
that Excel is making my first row a heading or something. How do I
modify this code or my spreadsheet so that the default A B C is
the heading and all rows of data I enter are treated as data and not a
heading. Thank you.
Sub ScratchMacro()
'Set Reference to "Microsoft DAO 3.51 (or 3.6) Object Library".
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim i As Long
Set db = OpenDatabase("C:\Book1", False, False, "Excel 8.0")
Set rs = db.OpenRecordset("SELECT * FROM `mySSRange`")
'Loop through each recordset.
While Not rs.EOF
For i = 0 To rs.Fields.Count - 1
MsgBox rs.Fields(i).Value
Next i
rs.MoveNext
Wend
'Clean up.
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub
contained a 3 x 3 cell range that I named "mySSrange"
In the cells I entered:
Cat Dog Hampster
Cow Pig Sheep
Wolf Badger Bear
When I run this code the first message displayed is "Cow." It seems
that Excel is making my first row a heading or something. How do I
modify this code or my spreadsheet so that the default A B C is
the heading and all rows of data I enter are treated as data and not a
heading. Thank you.
Sub ScratchMacro()
'Set Reference to "Microsoft DAO 3.51 (or 3.6) Object Library".
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim i As Long
Set db = OpenDatabase("C:\Book1", False, False, "Excel 8.0")
Set rs = db.OpenRecordset("SELECT * FROM `mySSRange`")
'Loop through each recordset.
While Not rs.EOF
For i = 0 To rs.Fields.Count - 1
MsgBox rs.Fields(i).Value
Next i
rs.MoveNext
Wend
'Clean up.
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub