Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
mel mel is offline
external usenet poster
 
Posts: 6
Default problem using Set statement to define range object

In the subroutine below I set a range variable SourceRng
= to a column in a named worksheet range. When I try to
use a for next to step through the cells in SourceRng I
get a type mismatch when comparing cel.value to the value
of a single cell. Using the immediate window I found The
cel.address to be a range (i.e. a1..a10) and not a cell
address (i.e. A1). I found a work around by selecting the
first column of the range and then using the set command
Set Sourcerng = selection, but why does the other not
work.


Sub getEmplDescrTest()
Dim SourceRng As Range, DestRng As Range, Cel As Range,
Mycel As Range
Set SourceRng = ActiveWorkbook.Worksheets("Fy2004").Range
("FY2004_personnel_list").Columns(3)
Set DestRng = ActiveWorkbook.Worksheets
("BossFy2004").Range("FY2004Boss_personnel_list"). Columns
(3)
'Set DestRng = ActiveWorkbook.Worksheets
("BossFy2004").Range("FY2004Boss_personnel_list ")
For Each Cel In DestRng ' just pick the name column of
the range
For Each Mycel In SourceRng
If Cel.Value = Mycel.Value Then
Cel.Offset(0, 2).Value = Mycel.Offset(0, -1).Value
End If
Next Mycel
Next Cel
'clear objects
Set SourceRng = Nothing
Set DestRng = Nothing
End Sub

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
Define Name range Gotroots Excel Discussion (Misc queries) 10 December 19th 09 11:30 AM
Define a range based on another named range Basil Excel Worksheet Functions 2 February 21st 05 01:47 PM
Range object to Array object conversion Myrna Larson[_2_] Excel Programming 1 August 1st 03 02:27 AM
Range object to Array object conversion Alan Beban[_3_] Excel Programming 0 August 1st 03 01:24 AM
Range object to Array object conversion Tom Ogilvy Excel Programming 0 August 1st 03 12:16 AM


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