Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate fields in excel from access form

Status
Not open for further replies.

access101

Programmer
Sep 4, 2010
68
US
i have a form with 60 textboxes named I1- I60

i need a for statement that will loop through and populate my excel spreadsheet
for this example
I1=54.25
I2=38.16
so far i have this which works but is not looping correctly
For a = 7 To 8
For b = 1 To 2
xlSheet.Range("d" & a) = Me("I" & b)
Next b, a

once i run the code

excel shows
d7 = 38.16
d8 = 38.16
 
It would help to understand you requirements better. However consider code like:

Code:
Public Function TestArray()
    Dim arI(2)
    Dim b As Integer
    arI(1) = 54.25
    arI(2) = 38.16
    For b = 1 To 2
        Debug.Print arI(b)
    Next
End Function

Duane
Hook'D on Access
MS Access MVP
 
access101 . . .

Just a guess ...
Code:
[blue]   Dim a As Long, b As Long
   
   For a = 7 To 8
      b = a - 6
      xlSheet.Range("d" & a) = Me("I" & b)
   Next[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
thanks TheAceMan1 that worked! I still don't understand why your code worked vs mine but appreciate the help.
 
access101 . . .

Hint! ... you only need one loop!

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top