Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Code Writing to Excel Box Name
Hi everyone,
Say you have a VBA code with FOR loop that solves and writes a solution each time to a single row in a Name Box. So, after each single solve you increase the line counter by 1 (INCREMENT=1) using Aline=Aline+1. So if we have 5 solves, then Name Box has the first 5 rows full. But, say a solution might take variable number of rows after each solve to write without leaving blanks in-between inside the Name Box. How do you make the INCREMENT variable then? Thanks, Mike |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Code Writing to Excel Box Name
Hi Mike
I'm not sure what you want, maybe post your code and explain what you want to change. This will find the last row and do what you want. Sub something() finalrow = Cells(Rows.Count, 1).End(xlUp).Row For i = 1 To finalrow If Cells(i, 1).Value = "Something" Then do something End If Next i End Sub HTH Cimjet "Mike" wrote in message ... Hi everyone, Say you have a VBA code with FOR loop that solves and writes a solution each time to a single row in a Name Box. So, after each single solve you increase the line counter by 1 (INCREMENT=1) using Aline=Aline+1. So if we have 5 solves, then Name Box has the first 5 rows full. But, say a solution might take variable number of rows after each solve to write without leaving blanks in-between inside the Name Box. How do you make the INCREMENT variable then? Thanks, Mike |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Code Writing to Excel Box Name
On Oct 20, 9:24*pm, "Cimjet" wrote:
Hi Mike I'm not sure what you want, maybe post your code and explain what you want to change. This will find the last row and do what you want. Sub something() finalrow = Cells(Rows.Count, 1).End(xlUp).Row For i = 1 To finalrow If Cells(i, 1).Value = "Something" Then do something End If Next i End Sub HTH Cimjet"Mike" wrote in message ... Hi everyone, Say you have a VBA code with FOR loop that solves and writes a solution each time to a single row in a Name Box. So, after each single solve you increase the line counter by 1 (INCREMENT=1) using Aline=Aline+1. So if we have 5 solves, then Name Box has the first 5 rows full. But, say a solution might take variable number of rows after each solve to write without leaving blanks in-between inside the Name Box. How do you make the INCREMENT variable then? Thanks, Mike- Hide quoted text - - Show quoted text - Say I have a table of 10 lines with a Name Box "ABC" as follows: 1 .1 .3 .7 2 .2 .3 .5 3 4 5 6 7 8 9 10 Now I have a WHILE Loop in which a model is solved everytime and a row or more get filled after each run. Because how many rows get filled each time is unknown, I need to find away to automate this so always the 1st blank row in "ABC" and that follow get filled. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Code Writing to Excel Box Name
On Oct 21, 8:04*am, Mike wrote:
On Oct 20, 9:24*pm, "Cimjet" wrote: Hi Mike I'm not sure what you want, maybe post your code and explain what you want to change. This will find the last row and do what you want. Sub something() finalrow = Cells(Rows.Count, 1).End(xlUp).Row For i = 1 To finalrow If Cells(i, 1).Value = "Something" Then do something End If Next i End Sub HTH Cimjet"Mike" wrote in message .... Hi everyone, Say you have a VBA code with FOR loop that solves and writes a solution each time to a single row in a Name Box. So, after each single solve you increase the line counter by 1 (INCREMENT=1) using Aline=Aline+1. So if we have 5 solves, then Name Box has the first 5 rows full. But, say a solution might take variable number of rows after each solve to write without leaving blanks in-between inside the Name Box. How do you make the INCREMENT variable then? Thanks, Mike- Hide quoted text - - Show quoted text - Say I have a table of 10 lines with a Name Box "ABC" as follows: 1 * .1 *.3 *.7 2 * .2 *.3 *.5 3 4 5 6 7 8 9 10 Now I have a WHILE Loop in which a model is solved everytime and a row or more get filled after each run. Because how many rows get filled each time is unknown, I need to find away to automate this so always the 1st blank row in "ABC" and that follow get filled. You can use a FOR loop for a known number of iterations. You can use a While loop for an unknown number of iterations. Example. I am trying to find the answer to X^3-x =5 Sub xxxxx() x = -1000 ' starting value for X E = 1000 ' starting value for the error in each guess e_tol = 0.1 ' acceptable amount of error leasterr = 10000 While Abs(E) e_tol x = x + 0.1 E = x ^ 3 - x - 5 If Abs(E) < leasterr Then bestx = x Ebest = E End If If x 1000 Then GoTo errmessage Wend MsgBox ("Answer = " & x) Exit Sub errmessage: MsgBox ("No solution found. Best solution: x= " & bestx & " error of " & Ebest) End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
IS IT POSSIBLE IN EXCEL WITHOUT WRITING CODE. | Excel Worksheet Functions | |||
Can you call a Web Service from Excel 2007 without writing code? | Excel Discussion (Misc queries) | |||
Writing and erasing code with code | Excel Programming | |||
Writing VBA code in Excel to Print Power point slides, and a PDF r | Excel Programming | |||
Importing XML into Excel 2000 without writing code | Excel Programming |