View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Excel VBA : Sheet selection

Must be that you are not using the correct objects. With an autofilter
applied, it still picked up every cell.

Sub Tester5()
Dim myRecord As Range
Dim myFiled As Range
For Each myRecord In Worksheets("Sheet1") _
.Range("A1").CurrentRegion.Rows

For Each myfield In myRecord.Cells
Debug.Print myfield.Address
Next myfield

Next myRecord

End Sub

Produced (data in A2:C5)
$A$1
$B$1
$C$1
$A$2
$B$2
$C$2
$A$3
$B$3
$C$3
$A$4
$B$4
$C$4
$A$5
$B$5
$C$5

if you don't want to process the first row:

Sub Tester5()
Dim myRecord As Range
Dim myFiled As Range
Dim rng as Range
set rng = Worksheets("Sheet1") _
.Range("A1").CurrentRegion.Rows
set rng = rng.offset(1,0).Resize(rng.rows.count-1)
For Each myRecord In rng
For Each myfield In myRecord.Cells
Debug.Print myfield.Address
Next myfield

Next myRecord

End Sub

--
Regards,
Tom Ogilvy



"vlbaranov " wrote in message
...
My appologoies Earl, I was just using the "Post Reply" and the only one
I see is at the end of the thread so thats the one I have used. I was
actually trying to reply to the post just before Tom's and not too sure
how it got to be after Tom's.
As per Tom's suggestion, I have tried it and don't get get any records
exported, stepped though the code and it seems it does not iterate
rather goes through the loop only once. I will keep trying (especially
hard with no help .. support yet to install) but in the meanwhile,
thank you all for the help and my appologies to the moderators for any
incorrect use of this forum.


---
Message posted from http://www.ExcelForum.com/