| | |
Range-objects, excel
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Sep 2009
Posts: 2
Reputation:
Solved Threads: 0
Hi guys,
I am writing (trying to write) a program in VBA for Excel 2003 and I got stuck, I need your help, please.
I have an excel range where the upmost cell is initially fixed and the downmost cell moves down as more data arrive.
In other words I have something like WorkRange = Range((1,1), (LastRow,1)).
In the range I have integers and LastValue is the value of the integer in cell (LastRow,1).
Over this range I calculate the maximum value (MaxVal) and the difference between LastValue and MaxVal.
So far it's (almost) easy, even for me.
Problem is, when the difference between LastValue and MaxVal satisfies a certain condition ( ie LastValue-MaxValue < z=constant) I need to move down the upmost cell in the WorkRange, so that it is set to coincide with the cell where the MaxVal is.
After that the program should me made to loop.
Normally the data series would be 40k rows long, but it could get 500k rows long I am afraid.
IN THEORY I have an idea of how I can solve this problem but I do not know how to do it practically with VBA.
I thought that maybe I could define the starting cell of the WorkRange as a Cell-object.
For example I could call it StartCell1. The WorkRange would then be:
WorkRange=Range(StartCell1,(LastRow,1)).
StartCell1 would be the first cell where I have data.
When condition ( LastValue-MaxValue < z) is satisfied I could create a Cell-object called LastCell1 that would be the first cell where the condition is satisfied.
I would also create a Cell-object called MaxVal1, that would be the cell where you find the maximum value in the range up to that point.
Finally I could also create a Range-object called WorkRange1=Range(StartCell1,LastCell1).
Done that I could create a new Cell-object, call it StartCell2 , and set it to have the same properties of Cell-object MaxVal1.
At that point the WorkRange would be WorkRange=Range(StartCell2,(LastRow,1)) and I could loop the program repeating the above.
Does it make sense ?
The problem is that I have no idea on how practically do this.
I am surfing through books and the web but did not find a solution so far. Can't see the shore either .... Anybody can please help ?
Thank you in advance
Frank
PS: I posted also yesterday but no replies. I hope I made my question clearer ...
I am writing (trying to write) a program in VBA for Excel 2003 and I got stuck, I need your help, please.
I have an excel range where the upmost cell is initially fixed and the downmost cell moves down as more data arrive.
In other words I have something like WorkRange = Range((1,1), (LastRow,1)).
In the range I have integers and LastValue is the value of the integer in cell (LastRow,1).
Over this range I calculate the maximum value (MaxVal) and the difference between LastValue and MaxVal.
So far it's (almost) easy, even for me.
Problem is, when the difference between LastValue and MaxVal satisfies a certain condition ( ie LastValue-MaxValue < z=constant) I need to move down the upmost cell in the WorkRange, so that it is set to coincide with the cell where the MaxVal is.
After that the program should me made to loop.
Normally the data series would be 40k rows long, but it could get 500k rows long I am afraid.
IN THEORY I have an idea of how I can solve this problem but I do not know how to do it practically with VBA.
I thought that maybe I could define the starting cell of the WorkRange as a Cell-object.
For example I could call it StartCell1. The WorkRange would then be:
WorkRange=Range(StartCell1,(LastRow,1)).
StartCell1 would be the first cell where I have data.
When condition ( LastValue-MaxValue < z) is satisfied I could create a Cell-object called LastCell1 that would be the first cell where the condition is satisfied.
I would also create a Cell-object called MaxVal1, that would be the cell where you find the maximum value in the range up to that point.
Finally I could also create a Range-object called WorkRange1=Range(StartCell1,LastCell1).
Done that I could create a new Cell-object, call it StartCell2 , and set it to have the same properties of Cell-object MaxVal1.
At that point the WorkRange would be WorkRange=Range(StartCell2,(LastRow,1)) and I could loop the program repeating the above.
Does it make sense ?
The problem is that I have no idea on how practically do this.
I am surfing through books and the web but did not find a solution so far. Can't see the shore either .... Anybody can please help ?
Thank you in advance
Frank
PS: I posted also yesterday but no replies. I hope I made my question clearer ...
![]() |
Similar Threads
- Open Excel file from Visual Basic (Visual Basic 4 / 5 / 6)
- opening Excel 2003 file by c# (C#)
- Defining Name Range While generating Excel from XML (XML, XSLT and XPATH)
- How to retrieve data from one form to another/ through Data Base (VB.NET)
- Excel: ledger, dynamically creating button (Visual Basic 4 / 5 / 6)
- how to link excel 2007 with VB.net (VB.NET)
- How to handle multiple files, to Excel (VB.NET)
- Trying to use a variable as a range reference in an excel chart (Visual Basic 4 / 5 / 6)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Copy Table Mysql to MS Access
- Next Thread: Copy Table Mysql to MS Access
| Thread Tools | Search this Thread |
Tag cloud for excel, movingranges, range-objects






