![]() |
Processing non-contiguous row selections
How do you manage to search through non contiguous... I'm pulling my
hair out on something similar (trying to search the cells in this order: Range("A1:C1,E1:G1,A4:C4,E4:G4,A7:C7,E7:G7,A10:C10 ,E10:G10" and so on) . Can you tell me how you do it, I think that could give me a start tks |
Processing non-contiguous row selections
Hi Caméléon,
Try something like: Sub Tester() Dim Rng As Range Dim Ar As Range Dim cell As Range Set Rng = _ Range("A1:C1,E1:G1,A4:C4,E4:G4,A7:C7,E7:G7,A10:C10 ,E10:G10") For Each Ar In Rng.Areas For Each cell In Ar MsgBox "Address: " & cell.Address(0, 0) & vbNewLine _ & "Value = " & cell.Value Next cell Next Ar End Sub -- --- Regards, Norman "Caméléon" wrote in message ups.com... How do you manage to search through non contiguous... I'm pulling my hair out on something similar (trying to search the cells in this order: Range("A1:C1,E1:G1,A4:C4,E4:G4,A7:C7,E7:G7,A10:C10 ,E10:G10" and so on) . Can you tell me how you do it, I think that could give me a start tks |
Processing non-contiguous row selections
Hi Caméléon,
It is unnecessary to iterate through the areas so, more simply: Sub Tester2() Dim Rng As Range Dim cell As Range Set Rng = _ Range("A1:C1,E1:G1,A4:C4,E4:G4,A7:C7,E7:G7,A10:C10 ,E10:G10") For Each cell In Rng MsgBox "Address: " & cell.Address(0, 0) & vbNewLine _ & "Value = " & cell.Value Next cell End Sub --- Regards, Norman "Norman Jones" wrote in message ... Hi Caméléon, Try something like: Sub Tester() Dim Rng As Range Dim Ar As Range Dim cell As Range Set Rng = _ Range("A1:C1,E1:G1,A4:C4,E4:G4,A7:C7,E7:G7,A10:C10 ,E10:G10") For Each Ar In Rng.Areas For Each cell In Ar MsgBox "Address: " & cell.Address(0, 0) & vbNewLine _ & "Value = " & cell.Value Next cell Next Ar End Sub -- --- Regards, Norman "Caméléon" wrote in message ups.com... How do you manage to search through non contiguous... I'm pulling my hair out on something similar (trying to search the cells in this order: Range("A1:C1,E1:G1,A4:C4,E4:G4,A7:C7,E7:G7,A10:C10 ,E10:G10" and so on) . Can you tell me how you do it, I think that could give me a start tks |
Processing non-contiguous row selections
Norman Jones wrote:
Hi Caméléon, Try something like: Sub Tester() Dim Rng As Range Dim Ar As Range Dim cell As Range Set Rng = _ Range("A1:C1,E1:G1,A4:C4,E4:G4,A7:C7,E7:G7,A10:C10 ,E10:G10") For Each Ar In Rng.Areas For Each cell In Ar MsgBox "Address: " & cell.Address(0, 0) & vbNewLine _ & "Value = " & cell.Value Next cell Next Ar End Sub Or perhaps just a single loop: For Each iCell in Rng .. . . Alan Beban |
Processing non-contiguous row selections
Hi Alan,
Or perhaps just a single loop Yes, as acknowledged in my second post: "It is unnecessary to iterate through the areas so, more simply: ...." --- Regards, Norman "Alan Beban" wrote in message ... Or perhaps just a single loop: For Each iCell in Rng . . . Alan Beban |
All times are GMT +1. The time now is 06:54 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com