Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Range type variable oddness

Nick,

Your Cells properties are not pointing to the TempData worksheet.
They refer to cells on the currently active worksheet. Try


With TempData
Set SearchRange = .Range(.Cells(1,1),.Cell(1,26))
End With

Note the three leading periods.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Nick" wrote in message
...
I wish to do this:

Dim TempData As Worksheet
Dim SearchRange As Range

Set TempData = ThisWorkbook.Worksheets("Temp Data")

Set SearchRange = TempData.Range(Cells(1, 1), Cells(1, 26))

The code currently comes up with an error message saying
the range method has failed.

I do need to declare tempdata and searchrange separately
cos I will be changing the searchrange in a "for, next"
loop.

I always thought that range was a property of worksheets
not a method. Bit confused and although I have tried many
different variations I can't get one to work.

Any reponse would be, as always, much appreciated.

Nick Shinkins



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Range type variable oddness

Thanks for all your replies.

Just got back to work to a complete solution :)

Should have known really since I have used the leading
periods on many past occasions.

The code works fine now.

Nick
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
setting a range variable equal to the value of a string variable Pilgrim Excel Programming 2 July 1st 04 11:32 PM
Trouble with variable type Ken McLennan[_3_] Excel Programming 2 June 2nd 04 08:04 AM
efine the data type of a variable monika Excel Programming 0 February 13th 04 02:01 AM
type variable as argument of a sub Koos Excel Programming 1 October 23rd 03 11:41 AM
Variable Type - help me to solve this choco140 Excel Programming 1 September 28th 03 10:39 AM


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