PDA

View Full Version : Multiselection areas: how to manage?



angelin
07-16-2010, 04:53 AM
:banghead:
Hi all: sorry for disturb you.
Have anybody any code example that show me how to manage rows (and some columns values) in a multiselection areas in excel 2003?
I have it done when I select one row or several continious rows, but if I select several not continous rows it only takes me the first selection.
Also, as I need to manage only some columns of each row each time, how can I acces it?. I`m using an array, and I fill it firstly with all the datas I need, and then, I read it each time I need to calculate something
Sorry again but I`m becoming crazy with this problem
Many thanks

p45cal
07-16-2010, 05:57 AM
but if I select several not continous rows it only takes me the first selectionTake each area of the selection in turn: Sub blah()
For Each are In Selection.Areas
are.Select 'or whatever
Next are
End Sub

Regarding "some columns of each row each time", what code have you got so far/are you processing just 1 or two columns or a whole raft of them in each row?
More info/context would help.

angelin
07-17-2010, 08:54 AM
Hi pa45l
thanks for your answer

I don`t know how to fix your code in my project. I need to fill an array with the content of serveral columns (not continued) of several rows (selected 1by 1, or with multiselection , all the same time)
I thought to use an redimnsionable array because I need to manage the selected datas to create envoices and delivery notes (calculating many thanks)

I attach you a file.
I hope you could help me because I don`t whwe to find any example to help me to fix this problem
thanks

p45cal
07-17-2010, 02:49 PM
The following code isn't very robust, it may not put things in the correct row order and rows may get copied over twice if selections are overlapping but you'll get my drift. I'm working on making it more robust and will post again if I find a way:
Sub blah()
Dim yyy As Range
If ActiveSheet.Name = "Sheet1" Then
Set xxx = Selection.EntireRow
For Each are In xxx.Areas
Intersect(are, Sheets("Sheet1").Range("A:C, E:F, J:J, L:L")).Copy Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Offset(1)
Next are
End If
End Sub