Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How scan specific column in each row?

Someone gave me the below code but it scans every cell.
It was useful but now I need to look in specific columns, how do I do that?
I'm sure this must be a pretty basic question.

Dim rCell As Range
Dim rRng As Range
With Worksheets("zKeyWordCount")
Set rRng = .Range("c1", .Cells(.Rows.Count, "C").End(xlUp))
End With
For Each rCell In rRng.Cells
....
Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default How scan specific column in each row?

If you drop .Cells from your If statement:

Dim rCell As Range
Dim rRng As Range
With Worksheets("zKeyWordCount")
Set rRng = .Range("c1", .Cells(.Rows.Count, "C").End(xlUp))
End With
For Each rCell In rRng 'Drop .Cells
....
Next

Then on my computer it only checks the cells in column "C"

"mscertified" wrote:

Someone gave me the below code but it scans every cell.
It was useful but now I need to look in specific columns, how do I do that?
I'm sure this must be a pretty basic question.

Dim rCell As Range
Dim rRng As Range
With Worksheets("zKeyWordCount")
Set rRng = .Range("c1", .Cells(.Rows.Count, "C").End(xlUp))
End With
For Each rCell In rRng.Cells
...
Next

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How scan specific column in each row?

Dim rCell As Range
dim rCell2 as range
Dim rRng As Range
With Worksheets("zKeyWordCount")
Set rRng = .Range("c1", .Cells(.Rows.Count, "C").End(xlUp))
End With
For Each rCell In rRng.Cells
'to look at all the cells in that row...
for each rcell2 in rcell.entirerow.cells
'...
next rcell2
next rcell

======
But you could use other things to look at a smaller set of cells

Dim rCell As Range
Dim rRng As Range
With Worksheets("zKeyWordCount")
Set rRng = .Range("c1", .Cells(.Rows.Count, "C").End(xlUp))
End With
For Each rCell In rRng.Cells
if rcell.offset(0,-2).value = "hi from column A" then
'do something
end if
if rcell.offset(0,3).value = "hi from column F" then
'do something else
end if
next rcell

Since you're looping through the cells in column C, you can use rcell.offset()
to go in either direction.



mscertified wrote:

Someone gave me the below code but it scans every cell.
It was useful but now I need to look in specific columns, how do I do that?
I'm sure this must be a pretty basic question.

Dim rCell As Range
Dim rRng As Range
With Worksheets("zKeyWordCount")
Set rRng = .Range("c1", .Cells(.Rows.Count, "C").End(xlUp))
End With
For Each rCell In rRng.Cells
...
Next


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How scan specific column in each row?

Dropping ".cells" from rRng does nothing different.

--
regards,
Tom Ogilvy

"JLGWhiz" wrote in message
...
If you drop .Cells from your If statement:

Dim rCell As Range
Dim rRng As Range
With Worksheets("zKeyWordCount")
Set rRng = .Range("c1", .Cells(.Rows.Count, "C").End(xlUp))
End With
For Each rCell In rRng 'Drop .Cells
...
Next

Then on my computer it only checks the cells in column "C"

"mscertified" wrote:

Someone gave me the below code but it scans every cell.
It was useful but now I need to look in specific columns, how do I do
that?
I'm sure this must be a pretty basic question.

Dim rCell As Range
Dim rRng As Range
With Worksheets("zKeyWordCount")
Set rRng = .Range("c1", .Cells(.Rows.Count, "C").End(xlUp))
End With
For Each rCell In rRng.Cells
...
Next



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
I need to scan a column Vercingetorix.XIII[_2_] Excel Worksheet Functions 6 September 23rd 08 05:23 PM
Scan column for first of a list Chip Excel Discussion (Misc queries) 1 May 24th 08 05:19 PM
Scan and remove column data query IE Excel Discussion (Misc queries) 5 March 23rd 07 09:50 AM
Scan and remove column data query IE Excel Worksheet Functions 5 March 23rd 07 09:50 AM
Find specific column titles and copy the column to new workboo JLGWhiz Excel Programming 0 December 11th 06 11:23 PM


All times are GMT +1. The time now is 09:42 PM.

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"