Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

values from field to array by macro

Hi all!

i have simple table with fields: country, sale, cost

now i need to fill arrow (My_array with data from field sale:  My_array = ActiveDocument.GetField ("Sale") 

and then i want calculate new arrow data in macro, example:  

for i=0 to My_arraycount

My_array_new = My_array + 10

next i

and finaly add new field to my table which contante My_array_new

is it possible in QV such opertiotion?

4 Replies
Not applicable
Author

Why You want to do it by macro?

Why don't You just use above() function?

Not applicable
Author

Hi!

I need try to do it by macros for another task.that is why this example is simple. in my real task i try to solve this:

1. rank customers by sale with some expression  main think: the most bigger customers those get 50% of total sale - rank "A", from 50%-80% - rank "B", from 80%-95% - rank "C", after 95% - rank "D". I use order by Sale desc field to get this.

2. rank customers by profit. I mean (sale / cost -1)  main think: the most bigger customers by (sale / cost -1) expression get 30% sale - rank "3", from 30%-70% - rank "2", after 70% - rank "1". I use order by (sale / cost -1) desc field to get this.

now i need join 2 rank in 1. it will be like:  A3, A2, A1, B3, B2 .... and s.o.

my problem is sorting: if i change sorting field, i lose my rank. that is why i thinking about macro

Not applicable
Author

i found how load data from field to array

sub ABC

     set val=ActiveDocument.Fields("Sale").GetSelectedValues

     for i=0 to val.Count-1

         val.Item(i).Number = val.Item(i).Number+10

     next

msgbox(val.Item(0).Number)

end sub

now how add field with this new data?

Not applicable
Author

solve by using macro and variables