LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Error with Range Object

Hi Helpers,

I'm trying to compare values from one spreadsheet to another and highligh
the cells in the original if they match. I've tried many things with the
range object but it doesn't work. I've narrowed it down to what I think the
problem is.

If I reference more than one workbook, it will fail. If I only reference
the original workbook, it works fine. Can you explain to me why this is?

Here is the narrowed down code. This code will work fine but if I uncomment
the reference to the other workbook it fails. Why is that? What can I do to
allow this? I'm using Excel 2003 but I would think 2007 can handle it the
same way.

Dim objBook As Workbook
Dim objSheet As Worksheet
Dim objOtherBook As Workbook
Dim objOtherSheet As Worksheet
Dim objShell As Object
Dim strPath As String

strRange = "A2:F2"
Set objBook = ThisWorkbook
Set objSheet = objBook.Sheets("Sheet1")
Set objShell = CreateObject("wscript.shell")
strPath = objShell.specialfolders("MyDocuments") & "\Referrals for Exam
and AM\Transmittals\"
'Set objOtherBook = Excel.Workbooks.Open(strPath & "2009 EFDS StartUp
Distribution List")
'Set objOtherSheet = objOtherBook.Sheets("TNSNames and WMS")

objSheet.Names.Add Name:="Data", RefersTo:="=" & strRange
objSheet.Range("Data").Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With

--
Thank You,
Keith
 
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
range object error BigJimmer Excel Programming 10 October 2nd 07 08:30 PM
STUPID range object error Susan Excel Programming 3 May 8th 07 09:06 PM
Range Object error NoSoupForYou Excel Programming 9 October 26th 06 01:46 AM
peculiar error with Range() object Jeff[_42_] Excel Programming 2 July 2nd 06 09:36 PM
Range Question / error 1004: method Range of object Worksheet has failed Paul Excel Programming 3 April 7th 05 02:56 PM


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