Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default 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
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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



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
excel processing Wendy Elizabeth Excel Worksheet Functions 1 June 18th 07 05:17 PM
Processing Data dan Excel Worksheet Functions 0 August 13th 06 02:33 AM
data processing Youyou Excel Discussion (Misc queries) 1 November 19th 05 10:42 AM
Conditional Processing Daniell Excel Discussion (Misc queries) 3 August 26th 05 12:45 AM
Data Processing Sedat Excel Programming 0 September 29th 03 05:22 PM


All times are GMT +1. The time now is 12:22 AM.

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

About Us

"It's about Microsoft Excel"