Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
For loop
hi,
I am looking for a formula that would give me a for loop. you can also give me a code in VB too.. This is what I am looking for in the for loop. i=0, j=0, k=0 i=0, j=0, k=1 i=0, j=0, k=2 i=0, j=0, k=3 i=0, j=1, k=0 i=0, j=1, k=1 i=0, j=1, k=2 i=0, j=1, k=3 and so on..... any ideas? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
For loop
What is i ? Is that always 0...Also you have not mentioned the condition to
end the loop. Try the below and view the result in immediate window.. Sub Macro_Increment() Dim i, j, k i = 0: j = 0: k = 0 Do If k = 4 Then j = j + 1: k = 0 Debug.Print i & "," & j & "," & k k = k + 1 Loop Until j = 10 End Sub If this post helps click Yes --------------- Jacob Skaria "Harish" wrote: hi, I am looking for a formula that would give me a for loop. you can also give me a code in VB too.. This is what I am looking for in the for loop. i=0, j=0, k=0 i=0, j=0, k=1 i=0, j=0, k=2 i=0, j=0, k=3 i=0, j=1, k=0 i=0, j=1, k=1 i=0, j=1, k=2 i=0, j=1, k=3 and so on..... any ideas? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
For loop
In a C program, I would always write my for loop like this:
for (i=0; i<=3; i++) { for (j=0; j<=3; j++) { for (k=0l k<=3; k++) { printf ("i = %d, j= %d, k=%d\n", i, j, k) } } } this code will give the result that i mentioned before in my post. In VB i m not sure how that's done but i want the code to input the value into the cell automatically. any ideas? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
For loop
Option Explicit
Sub testme() Dim i as long dim j as long dim k as long for i = 0 to 3 for j = 0 to 3 for k = 0 to 3 msgbox i & " " & j & " " & k next k next j next i End sub But I'm not sure what cells you want to populate. Harish wrote: In a C program, I would always write my for loop like this: for (i=0; i<=3; i++) { for (j=0; j<=3; j++) { for (k=0l k<=3; k++) { printf ("i = %d, j= %d, k=%d\n", i, j, k) } } } this code will give the result that i mentioned before in my post. In VB i m not sure how that's done but i want the code to input the value into the cell automatically. any ideas? -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
For loop
I want the code to enter these values in the excel cells columns, A, B
and C. How do i do that? |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
For loop
i want the code to enter the values of i, j, and k into the excel
spreadsheet columns A, B and C automatically |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
For loop
What is the line to store values in a cell?
|
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
For loop
Sub LoopTest()
Dim lngRow, lngA, lngB, lngC As Long lngRow = 1 For lngA = 0 To 3 For lngB = 0 To 3 For lngC = 0 To 3 ActiveSheet.Range("A" & lngRow) = lngA ActiveSheet.Range("B" & lngRow) = lngB ActiveSheet.Range("C" & lngRow) = lngC lngRow = lngRow + 1 Next Next Next End Sub If this post helps click Yes --------------- Jacob Skaria "Harish" wrote: In a C program, I would always write my for loop like this: for (i=0; i<=3; i++) { for (j=0; j<=3; j++) { for (k=0l k<=3; k++) { printf ("i = %d, j= %d, k=%d\n", i, j, k) } } } this code will give the result that i mentioned before in my post. In VB i m not sure how that's done but i want the code to input the value into the cell automatically. any ideas? |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
For loop
Thanks a lot Jacob.
|
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
For loop
I have another problem and i think a nested for loop is applicable on
this problem I have the following data: x1 x3 x2 26.563 24.644 1.72 26.826 24.888 1.72 27.089 25.132 1.72 27.352 25.376 1.72 27.615 25.62 1.72 27.878 25.864 1.72 28.141 26.108 1.72 28.404 26.352 1.72 28.667 26.596 1.72 28.93 26.84 1.72 29.193 27.084 1.72 29.456 27.328 1.72 29.719 27.572 1.72 29.982 27.816 1.72 30.245 28.06 1.72 30.508 28.304 1.72 30.771 28.548 1.72 31.034 28.792 1.72 31.297 29.036 1.72 31.56 29.28 1.72 I have an equation that uses these 3 values. For example, x1 will be held constant, while x3 changes for every iteration and then x1 will change and after x3 will keep changing for every iteration....this is similar to that for loop we just developed except i don;t know how to read the values off the excel spreadsheet using VB since i m new to VB. Appreciate your help. Thanks |
#11
Posted to microsoft.public.excel.programming
|
|||
|
|||
For loop
How do i iterate the cells in for loop?
|
#12
Posted to microsoft.public.excel.programming
|
|||
|
|||
For loop
how do i iterate the cells in the for loop?
|
#13
Posted to microsoft.public.excel.programming
|
|||
|
|||
For loop
How do I iterate the cells?
On Apr 29, 2:00*am, Harish wrote: I have another problem and i think a nested for loop is applicable on this problem I have the following data: x1 * * *x3 * * *x2 26.563 *24.644 *1.72 26.826 *24.888 *1.72 27.089 *25.132 *1.72 27.352 *25.376 *1.72 27.615 *25.62 * 1.72 27.878 *25.864 *1.72 28.141 *26.108 *1.72 28.404 *26.352 *1.72 28.667 *26.596 *1.72 28.93 * 26.84 * 1.72 29.193 *27.084 *1.72 29.456 *27.328 *1.72 29.719 *27.572 *1.72 29.982 *27.816 *1.72 30.245 *28.06 * 1.72 30.508 *28.304 *1.72 30.771 *28.548 *1.72 31.034 *28.792 *1.72 31.297 *29.036 *1.72 31.56 * 29.28 * 1.72 I have an equation that uses these 3 values. For example, x1 will be held constant, while x3 changes for every iteration and then x1 will change and after x3 will keep changing for every iteration....this is similar to that for loop we just developed except i don;t know how to read the values off the excel spreadsheet using VB since i m new to VB. Appreciate your help. Thanks |
#14
Posted to microsoft.public.excel.programming
|
|||
|
|||
For loop
I thought Jacob's suggestion showed you how to do that.
Harish wrote: What is the line to store values in a cell? -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
returning back to loop check condition without completing the loop | Excel Programming | |||
Loop to Filter, Name Sheets. If Blank, Exit Loop | Excel Programming | |||
(Complex) Loop within loop to create worksheets | Excel Programming | |||
Advancing outer Loop Based on criteria of inner loop | Excel Programming | |||
Problem adding charts using Do-Loop Until loop | Excel Programming |