Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IS IT POSSIBLE IN EXCEL WITHOUT WRITING CODE. HARSHAWARDHAN. S .SHASTRI[_2_] Excel Worksheet Functions 14 February 4th 09 04:48 PM
Can you call a Web Service from Excel 2007 without writing code? BigBadBubba Excel Discussion (Misc queries) 0 March 14th 07 03:32 AM
Writing and erasing code with code bobbo Excel Programming 4 October 11th 06 08:28 PM
Writing VBA code in Excel to Print Power point slides, and a PDF r QuietMan Excel Programming 6 September 26th 06 12:30 AM
Importing XML into Excel 2000 without writing code jjmmbb Excel Programming 3 May 10th 05 10:02 PM


All times are GMT +1. The time now is 10:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"