943,892 Members | Top Members by Rank

Ad:
Aug 17th, 2008
0

Do while loop

Expand Post »
I'm trying to create a do while loop where I can automatically fill cells A11 with the numbers 4 to 1 respectively. can anyone help??
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
herephishy is offline Offline
9 posts
since Aug 2008
Aug 17th, 2008
0

Re: Do while loop

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

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1.  
  2. Dim colVar As Integer
  3. Dim colChars As String
  4. Dim cellAdd As String
  5.  
  6. colChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  7.  
  8. For colVar = 1 To 4
  9. cellAdd = Mid(colChars, colVar, 1) & 1
  10. Range(cellAdd).Value = colVar
  11. Next colVar

Hope this solves ur problem.


Regards
Shaik Akthar
Reputation Points: 26
Solved Threads: 40
Posting Whiz
aktharshaik is offline Offline
316 posts
since Aug 2008
Aug 17th, 2008
0

Re: Do while loop

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim colVar As Integer
  2. Dim noOfCols As Integer
  3. Dim colChars As String
  4. Dim cellAdd As String
  5.  
  6. colChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  7.  
  8. 'This piece of code holds good
  9. 'for Columns upto 26 only
  10. 'Because beyond that the col names will
  11. 'be AA, AB, AC,...
  12. 'Then u may have to create and array
  13. 'using a loop to store the column names
  14.  
  15. noOfCols = 10
  16.  
  17. For colVar = 1 To noOfCols
  18. cellAdd = Mid(colChars, colVar, 1) & 1
  19. Range(cellAdd).Value = noOfCols - colVar + 1
  20. Next colVar



Hope this solves ur problem.


Regards
Shaik Akthar
Last edited by aktharshaik; Aug 17th, 2008 at 1:23 pm.
Reputation Points: 26
Solved Threads: 40
Posting Whiz
aktharshaik is offline Offline
316 posts
since Aug 2008
Aug 17th, 2008
0

Re: Do while loop

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
Reputation Points: 26
Solved Threads: 40
Posting Whiz
aktharshaik is offline Offline
316 posts
since Aug 2008
Aug 17th, 2008
0

Re: Do while loop

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
herephishy is offline Offline
9 posts
since Aug 2008
Aug 17th, 2008
0

Re: Do while loop

U have to take another Variable

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. I = 1
  2. N = 5
  3. Do While I < N
  4. Cells(1,I) = N - I
  5. I = I + 1
  6. Loop



Regards
Shaik Akthar
Reputation Points: 26
Solved Threads: 40
Posting Whiz
aktharshaik is offline Offline
316 posts
since Aug 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Using search command in the database. . .help
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: is this the correct answer??





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC