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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

fill across row instead of down column

Status
Not open for further replies.

xxentric

Technical User
Oct 14, 2009
35
0
0
US
(i think i may have posted this in the wrong forum before)
i have just a loop code here as an example of how im filling data down a column... how could i do this the other way and have it fill the data across a row instead?

Code:
Do While myRecSet.EOF = False
    myRecipe(i) = CStr(myRecSet.Fields(0).Value)

    ThisWorkbook.Worksheets("Sheet1").Range("A" & 8 + i).Value = myRecSet.Fields(0).Value

    myRecSet.MoveNext
    i = i + 1
Loop
 
use the "row, column" index style for cell/range reference.

Where you have:
Code:
ThisWorkbook.Worksheets("Sheet1").Range("A" & 8 + i)
you could write, instead:
Code:
ThisWorkbook.Worksheets("Sheet1").cells(8 + i,1)
i.e., row, 8+i, column, 1.
Then, to transpose:
Code:
ThisWorkbook.Worksheets("Sheet1").cells(r, c+i)

_________________
Bob Rashkin
 
i = 1
Do While Not myRecSet.EOF
ThisWorkbook.Worksheets("Sheet1").Cells(8, i).Value = myRecSet.Fields(0).Value
myRecSet.MoveNext
i = i + 1
Loop

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top