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

Hi everbody!

I encounter a problem with a sub of mine. It generates a runtime error
Incompatible types in the line marked.
(This is a simplified version of the macro that generates the sam
error..)

Dim pTabell As Range
Dim id As Range

Set pTabell = Range("A6:H370")

If Union(Range("G27"), pTabell).Address = pTabell.Address Then
For Each id In pTabell.Columns(1) <----ERROR
If id.FormulaR1C1 = Range("G27").FormulaR1C1 Then
id.Offset(0, Range("G27").Column - 1).Value
Range("G27").Value
End If
Next id
End If


If I switch the For Each... line to
For Each id In Range("A6:A370") (Which is what I intend in th
previous code..)
then it works like planned.

Isn't the pTabell.Columns(1) and Range("A6:A370") addressing the sam
range?

What am I doing wrong?

/Henri

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Iterating through cells problem

Hi Henrik,

Try changing:

For Each id In pTabell.Columns(1)
to :
For Each id In pTabell.Columns(1).cells

---
Regards,
Norman


"heenchi " wrote in message
...
Hi everbody!

I encounter a problem with a sub of mine. It generates a runtime error:
Incompatible types in the line marked.
(This is a simplified version of the macro that generates the same
error..)

Dim pTabell As Range
Dim id As Range

Set pTabell = Range("A6:H370")

If Union(Range("G27"), pTabell).Address = pTabell.Address Then
For Each id In pTabell.Columns(1) <----ERROR
If id.FormulaR1C1 = Range("G27").FormulaR1C1 Then
id.Offset(0, Range("G27").Column - 1).Value =
Range("G27").Value
End If
Next id
End If


If I switch the For Each... line to
For Each id In Range("A6:A370") (Which is what I intend in the
previous code..)
then it works like planned.

Isn't the pTabell.Columns(1) and Range("A6:A370") addressing the same
range?

What am I doing wrong?

/Henrik


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



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 files in folder Minerva Excel Worksheet Functions 1 January 11th 06 10:00 AM
Iterating through string in a cell joeboe Excel Discussion (Misc queries) 1 October 7th 05 08:52 AM
iterating checkboxes [email protected] Excel Discussion (Misc queries) 1 May 11th 05 08:42 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 03:10 PM.

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

About Us

"It's about Microsoft Excel"