Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default How to loop through cells in a column?

My goal is to find a row of data that has more than 255 characters in column L.

This works for one cell:
x = Len(Range("L2"))

Can someone help me with looping through cells L2, L3, L4 and so on--keeping
in mind that I need to use the Len function--so that I can perform an action
when I find a row that meets the criteria.

Thank you,
Judy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default How to loop through cells in a column?

hi
this should work. you were a little foggy about what action you wanted to
perform so i just colored the cell.
Sub findit()
Dim lc As Long
lc = Cells(Rows.Count, "L").End(xlUp).Row
For Each cell In Range("L1:L" & lc)
If Len(cell) 255 Then
cell.Interior.ColorIndex = 3
End If
Next cell

End Sub

regards
FSt1

"Judy Ward" wrote:

My goal is to find a row of data that has more than 255 characters in column L.

This works for one cell:
x = Len(Range("L2"))

Can someone help me with looping through cells L2, L3, L4 and so on--keeping
in mind that I need to use the Len function--so that I can perform an action
when I find a row that meets the criteria.

Thank you,
Judy

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 185
Default How to loop through cells in a column?

Judy

You can loop through a collection using a For...Next loop like so

Sub Find Over255()
Dim myCell as Range
For Each myCell in Range("L1:L100")
If Len(myCell.Value)255 Then
'Do what you want here
End If
Next myCell
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
web:
www.excelusergroup.org
web: www.nickhodge.co.uk





"Judy Ward" wrote in message
...
My goal is to find a row of data that has more than 255 characters in
column L.

This works for one cell:
x = Len(Range("L2"))

Can someone help me with looping through cells L2, L3, L4 and so
on--keeping
in mind that I need to use the Len function--so that I can perform an
action
when I find a row that meets the criteria.

Thank you,
Judy


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How to loop through cells in a column?

Dim myRng as range
dim myCell as range

with worksheets("somesheetnamehere")
set myrng = .range("L2", .cells(.rows.count,"L").end(xlup))
end with

for each mycell in myrng.cells
if len(mycell.value) 255 then
msgbox mycell.address(0,0)
'stop looking???
exit for
end if
next mycell

Judy Ward wrote:

My goal is to find a row of data that has more than 255 characters in column L.

This works for one cell:
x = Len(Range("L2"))

Can someone help me with looping through cells L2, L3, L4 and so on--keeping
in mind that I need to use the Len function--so that I can perform an action
when I find a row that meets the criteria.

Thank you,
Judy


--

Dave Peterson
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
Display cells(text) in one column based on cells which are present inother column [email protected] Excel Discussion (Misc queries) 1 May 12th 08 01:40 PM
Loop Column Lisa Excel Discussion (Misc queries) 2 July 17th 07 06:14 PM
Loop through column headers to search from column name and get cell range Pie Excel Programming 9 December 29th 05 12:17 AM
Help - loop through cells in a range that are not together (several different cells as Target) Marie J-son[_5_] Excel Programming 4 April 3rd 05 09:54 PM
HOW-TO? Loop through cells in a column Mr. Clean[_2_] Excel Programming 4 December 12th 03 08:28 PM


All times are GMT +1. The time now is 12:24 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"