Do while loop

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Aug 2008
Posts: 9
Reputation: herephishy is an unknown quantity at this point 
Solved Threads: 0
herephishy herephishy is offline Offline
Newbie Poster

Do while loop

 
0
  #1
Aug 17th, 2008
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??
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 304
Reputation: aktharshaik is an unknown quantity at this point 
Solved Threads: 37
aktharshaik's Avatar
aktharshaik aktharshaik is offline Offline
Posting Whiz

Re: Do while loop

 
0
  #2
Aug 17th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 304
Reputation: aktharshaik is an unknown quantity at this point 
Solved Threads: 37
aktharshaik's Avatar
aktharshaik aktharshaik is offline Offline
Posting Whiz

Re: Do while loop

 
0
  #3
Aug 17th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 304
Reputation: aktharshaik is an unknown quantity at this point 
Solved Threads: 37
aktharshaik's Avatar
aktharshaik aktharshaik is offline Offline
Posting Whiz

Re: Do while loop

 
0
  #4
Aug 17th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 9
Reputation: herephishy is an unknown quantity at this point 
Solved Threads: 0
herephishy herephishy is offline Offline
Newbie Poster

Re: Do while loop

 
0
  #5
Aug 17th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 304
Reputation: aktharshaik is an unknown quantity at this point 
Solved Threads: 37
aktharshaik's Avatar
aktharshaik aktharshaik is offline Offline
Posting Whiz

Re: Do while loop

 
0
  #6
Aug 17th, 2008
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
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC