B
BTU_needs_assistance_43
I've got a program set up to pull out entire rows of data from Excel into an
Access table but I've hit a small snag. One of 3 cells of information I want
included in at the end of each row of data I pull are in a completely
seperate section. The initial value in each row (a, b, or c) determines which
of the cells I need to pull in. (C62, C64, C66). I want to enter the data
from this cell into the last field of my Access table so that I can use it in
a query later to draw various data tables together. The values in cells B62,
B64, and B66 are identical to the values in the initial cell rows so I do
have something to compare to figure out which cell I need to include. But I'm
hitting a total brick wall. It looks something like this below and below that
I'm posting what code I have.
ex:
a X X X
a X X X
b X X X
b X X X
c X X X
c X X X
a XXX
b XXX
c XXX
CODE:
Set xlc = xls.Range("B5") ' this is the first cell that contains data
Do Until xlc.Value = "0" ' sets limit value for loop to stop at
Set rst = dbs.OpenRecordset("Cast Reports", dbOpenDynaset, dbAppendOnly)
rst.AddNew
For lngColumn = 0 To rst.Fields.Count - 2
For x = 1 To xls.Columns.Count - 1
.Value(x) = xlc.Range(lngRow, 0).Value
If rst.Fields(lngRow).Value = vDate1 Then
rst.Fields(lngColumn).Value = xlc.Offset(0, lngColumn).Value
rst![Shot Date] = vDate1
ElseIf rst.Fields(lngRow).Value = vDate2 Then
rst.Fields(lngColumn).Value = xlc.Offset(0, lngColumn).Value
rst![Shot Date] = vDate2
ElseIf rst.Fields(lngRow).Value = vDate3 Then
rst.Fields(lngColumn).Value = xlc.Offset(0, lngColumn).Value
rst![Shot Date] = vDate3
End If
Next lngRow
Next lngColumn
rst.Update
Set xlc = xlc.Offset(1, 0)
Loop
Access table but I've hit a small snag. One of 3 cells of information I want
included in at the end of each row of data I pull are in a completely
seperate section. The initial value in each row (a, b, or c) determines which
of the cells I need to pull in. (C62, C64, C66). I want to enter the data
from this cell into the last field of my Access table so that I can use it in
a query later to draw various data tables together. The values in cells B62,
B64, and B66 are identical to the values in the initial cell rows so I do
have something to compare to figure out which cell I need to include. But I'm
hitting a total brick wall. It looks something like this below and below that
I'm posting what code I have.
ex:
a X X X
a X X X
b X X X
b X X X
c X X X
c X X X
a XXX
b XXX
c XXX
CODE:
Set xlc = xls.Range("B5") ' this is the first cell that contains data
Do Until xlc.Value = "0" ' sets limit value for loop to stop at
Set rst = dbs.OpenRecordset("Cast Reports", dbOpenDynaset, dbAppendOnly)
rst.AddNew
For lngColumn = 0 To rst.Fields.Count - 2
For x = 1 To xls.Columns.Count - 1
.Value(x) = xlc.Range(lngRow, 0).Value
If rst.Fields(lngRow).Value = vDate1 Then
rst.Fields(lngColumn).Value = xlc.Offset(0, lngColumn).Value
rst![Shot Date] = vDate1
ElseIf rst.Fields(lngRow).Value = vDate2 Then
rst.Fields(lngColumn).Value = xlc.Offset(0, lngColumn).Value
rst![Shot Date] = vDate2
ElseIf rst.Fields(lngRow).Value = vDate3 Then
rst.Fields(lngColumn).Value = xlc.Offset(0, lngColumn).Value
rst![Shot Date] = vDate3
End If
Next lngRow
Next lngColumn
rst.Update
Set xlc = xlc.Offset(1, 0)
Loop