I'm trying to create a do while loop where I can automatically fill cells A1:D1 with the numbers 4 to 1 respectively. can anyone help??

There r so many ways to loop.
Try this one.

Dim colVar As Integer
    Dim colChars As String
    Dim cellAdd As String

    colChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

    For colVar = 1 To 4
        cellAdd = Mid(colChars, colVar, 1) & 1
        Range(cellAdd).Value = colVar
    Next colVar

Hope this solves ur problem.


Regards
Shaik Akthar

Dim colVar As Integer
    Dim noOfCols As Integer
    Dim colChars As String
    Dim cellAdd As String

    colChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

    'This piece of code holds good 
    'for Columns upto 26 only
    'Because beyond that the col names will
    'be AA, AB, AC,...
    'Then u may have to create and array
    'using a loop to store the column names

    noOfCols = 10

    For colVar = 1 To noOfCols
        cellAdd = Mid(colChars, colVar, 1) & 1
        Range(cellAdd).Value = noOfCols - colVar + 1
    Next colVar

Hope this solves ur problem.


Regards
Shaik Akthar

Dear herephishy,
plz dont break the thread. continue ur queries in the previous thread itself. so that u can get all ur related solutions in one single thread. this is just a piece of advice. hope i didn't say anything wrong

Regards
Shaik Akthar

ok so if the following produces numbers 1 thru 4 in Columns A1 thru D4, how would I produce 4 thru 1 in columns A1-D4??

I = 1
Do While I < 5
Cells(1, I).Value = I
I = I + 1
Loop

U have to take another Variable

I = 1
N = 5
Do While I < N
    Cells(1,I) = N - I
    I = I + 1
Loop

Regards
Shaik Akthar

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.