Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Iterating Thru Cells

Hi -

Can anyone clue me in as to why the following code won't iterate down thru
cells getting the value from each & comparing it to a value obtained arlier
in the function?

Many thanks,

Kelvin

'Loop down thru cells, finding match on Room No:
Do While Not IsEmpty(ActiveCell)
If ActiveCell.Interior.ColorIndex < 35 Then 'Cell not
unavailable
If ActiveCell.Value = RoomNumber Then
If Len(StaffName) = 0 Then
StaffName = ActiveCell.Value
Else
StaffName = StaffName & Chr$(13) & ActiveCell.Value
End If
End If
End If
ActiveCell.Offset(1, 0).Activate 'Move down one cell
Loop





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default Iterating Thru Cells

Hi Kelvin

looks fine to me except that a cell with only a background fill is
considered empty and therefore the code will end at this point.

Cheers
JulieD

"Kelvin Clayson" wrote in message
...
Hi -

Can anyone clue me in as to why the following code won't iterate down thru
cells getting the value from each & comparing it to a value obtained
arlier
in the function?

Many thanks,

Kelvin

'Loop down thru cells, finding match on Room No:
Do While Not IsEmpty(ActiveCell)
If ActiveCell.Interior.ColorIndex < 35 Then 'Cell not
unavailable
If ActiveCell.Value = RoomNumber Then
If Len(StaffName) = 0 Then
StaffName = ActiveCell.Value
Else
StaffName = StaffName & Chr$(13) & ActiveCell.Value
End If
End If
End If
ActiveCell.Offset(1, 0).Activate 'Move down one cell
Loop







  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Iterating Thru Cells

Hi Kelvin,

Is it really a Function or did you mean a Sub? You can't activate cells from
a function; you can just return a value, replacing the function call.

--

Kind Regards,

Niek Otten

Microsoft MVP - Excel

"Kelvin Clayson" wrote in message
...
Hi -

Can anyone clue me in as to why the following code won't iterate down thru
cells getting the value from each & comparing it to a value obtained
arlier
in the function?

Many thanks,

Kelvin

'Loop down thru cells, finding match on Room No:
Do While Not IsEmpty(ActiveCell)
If ActiveCell.Interior.ColorIndex < 35 Then 'Cell not
unavailable
If ActiveCell.Value = RoomNumber Then
If Len(StaffName) = 0 Then
StaffName = ActiveCell.Value
Else
StaffName = StaffName & Chr$(13) & ActiveCell.Value
End If
End If
End If
ActiveCell.Offset(1, 0).Activate 'Move down one cell
Loop







  #4   Report Post  
Posted to microsoft.public.excel.programming
N10 N10 is offline
external usenet poster
 
Posts: 141
Default Iterating Thru Cells

Hi

Could be this line

ActiveCell.Offset(1, 0).Activate 'Move down one cell

how about

ActiveCell.Offset(1, 0).select

Best N10



"Kelvin Clayson" wrote in message
...
Hi -

Can anyone clue me in as to why the following code won't iterate down thru
cells getting the value from each & comparing it to a value obtained
arlier
in the function?

Many thanks,

Kelvin

'Loop down thru cells, finding match on Room No:
Do While Not IsEmpty(ActiveCell)
If ActiveCell.Interior.ColorIndex < 35 Then 'Cell not
unavailable
If ActiveCell.Value = RoomNumber Then
If Len(StaffName) = 0 Then
StaffName = ActiveCell.Value
Else
StaffName = StaffName & Chr$(13) & ActiveCell.Value
End If
End If
End If
ActiveCell.Offset(1, 0).Activate 'Move down one cell
Loop







  #5   Report Post  
Posted to microsoft.public.excel.programming
N10 N10 is offline
external usenet poster
 
Posts: 141
Default Iterating Thru Cells

Repsoted

ActiveCell.Offset(1, 0).Activate 'Move down one cell

try

ActiveCell.Offset(1, 0).select

N10

"Kelvin Clayson" wrote in message
...
Hi -

Can anyone clue me in as to why the following code won't iterate down thru
cells getting the value from each & comparing it to a value obtained
arlier
in the function?

Many thanks,

Kelvin

'Loop down thru cells, finding match on Room No:
Do While Not IsEmpty(ActiveCell)
If ActiveCell.Interior.ColorIndex < 35 Then 'Cell not
unavailable
If ActiveCell.Value = RoomNumber Then
If Len(StaffName) = 0 Then
StaffName = ActiveCell.Value
Else
StaffName = StaffName & Chr$(13) & ActiveCell.Value
End If
End If
End If
ActiveCell.Offset(1, 0).Activate 'Move down one cell
Loop









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Iterating Thru Cells

Julie -

Yeah that was it... almost there now!!

Thanks v.much

Kelvin
"JulieD" wrote in message
...
Hi Kelvin

looks fine to me except that a cell with only a background fill is
considered empty and therefore the code will end at this point.

Cheers
JulieD

"Kelvin Clayson" wrote in message
...
Hi -

Can anyone clue me in as to why the following code won't iterate down

thru
cells getting the value from each & comparing it to a value obtained
arlier
in the function?

Many thanks,

Kelvin

'Loop down thru cells, finding match on Room No:
Do While Not IsEmpty(ActiveCell)
If ActiveCell.Interior.ColorIndex < 35 Then 'Cell not
unavailable
If ActiveCell.Value = RoomNumber Then
If Len(StaffName) = 0 Then
StaffName = ActiveCell.Value
Else
StaffName = StaffName & Chr$(13) & ActiveCell.Value
End If
End If
End If
ActiveCell.Offset(1, 0).Activate 'Move down one cell
Loop









  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Iterating Thru Cells

Thanks for that, I changed the line & this compared with the solution above
sorted this bit out - many thanks!

Kelvin
"N10" wrote in message
...
Hi

Could be this line

ActiveCell.Offset(1, 0).Activate 'Move down one cell

how about

ActiveCell.Offset(1, 0).select

Best N10



"Kelvin Clayson" wrote in message
...
Hi -

Can anyone clue me in as to why the following code won't iterate down

thru
cells getting the value from each & comparing it to a value obtained
arlier
in the function?

Many thanks,

Kelvin

'Loop down thru cells, finding match on Room No:
Do While Not IsEmpty(ActiveCell)
If ActiveCell.Interior.ColorIndex < 35 Then 'Cell not
unavailable
If ActiveCell.Value = RoomNumber Then
If Len(StaffName) = 0 Then
StaffName = ActiveCell.Value
Else
StaffName = StaffName & Chr$(13) & ActiveCell.Value
End If
End If
End If
ActiveCell.Offset(1, 0).Activate 'Move down one cell
Loop









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
Iterating thru cells & comparing Kelvin Clayson Excel Programming 1 November 5th 04 07:12 PM
Iterating through cells problem heenchi[_2_] Excel Programming 1 June 9th 04 11:54 PM
Iterating through cells problem heenchi Excel Programming 1 June 9th 04 06:25 PM
Iterating through Cells .Net/Excel 2003 R Kalal Excel Programming 6 February 20th 04 01:13 AM
Iterating through row cells on column Match, help please. FrankBooth Excel Programming 0 July 8th 03 03:00 PM


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