Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Calculated value based on current line selection

I have just about refined my entire project. I'm down to
this part here. Again, this code works. However, I want it
to be as well written as it can be.

Notice the lines below that start with:
Range("A1").End(xlDown).Offset(1, 0).Select
ActiveCell.Formula = sformula
Selection.Copy
Selection.PasteSpecial xlPasteValues

This top line goes to a blank line. I found so far that I
had to select it because of the fact that I have a
spreadsheet range referenced in sformula below that
depends on the value of the range lines1, and its formula
is: "=CELL("ROW")-2". So, this means if the selection in
this case in on row 4080, then the value of lines1 in that
case is 4078. That value is a part of the result of the
formula sformula. So, is there any other way to pass that
result to sformula if the active cell isn't there?

After the formula result is done, then it has to paste its
value in the active cell, which is what the last two lines
above are for. Finally it passes the value of lines1 over
to the range lines 2, so that on the 2nd and subsequent
passes, the current row selection less the 4078 gets
caculated in formula sformula. So, next time, it ends up
being only 80.

The complete with section is reprinted below if you want
to see how that portion fits together.




With Sheets("Data_Assembly")
.Range("Workarea").Resize(8).Value = Range _
("Sum_it").Resize(8).Value
.Range("Workarea").CurrentRegion.Copy
End With
With Sheets("Report")
.Range("A1").End(xlDown).Offset(1, 0).PasteSpecial _
xlPasteValues

sformula = "=IF(FIXED(INDEX(Summary,ROWSUM+1,2),0,TRUE)
=INDEX(Summary,ROWSUM+1,1)," & _
"""SE~""&FIXED(LINES1,0,TRUE)&""~0001""," & _
"""SE~""&FIXED(LINES1-LINES2,0)&""~0001"")"
Range("A1").End(xlDown).Offset(1, 0).Select
ActiveCell.Formula = sformula
Selection.Copy
Selection.PasteSpecial xlPasteValues
Range("Lines2") = Range("lines1")
End With
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
I want to create a calculated item based on a calculated field Stijn Excel Discussion (Misc queries) 1 August 25th 08 05:30 PM
Modify a calculated field formula depending upon selection of pagefield Tewari Excel Discussion (Misc queries) 0 April 10th 07 01:35 PM
How do I convert a formula calculated number to a current value ? Chandler New Users to Excel 2 January 2nd 06 12:44 AM
How do I get a value of a calculated point on an excel line chart? klc6778 Charts and Charting in Excel 3 September 26th 05 02:17 AM
excel change default column sort to current selection john palmer Excel Worksheet Functions 2 March 8th 05 03:07 PM


All times are GMT +1. The time now is 06:59 PM.

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

About Us

"It's about Microsoft Excel"