Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Range Question

I have the following and am receiving a run time error 1004. Application
defined or Object Defined error.

What am I doing incorrectly?

Worksheets(1).Activate
If CheckBox1.Value = True Then
Set rg1 = Range("A17:F17")
Sheets(1).Range("rg1").Interior.Color = vbYellow
Else

I am trying to select the cells from A17 - F17 and highlight them yellow.

Thank you,
Roger


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 310
Default Range Question

You need to replace the line...

Sheets(1).Range("rg1").Interior.Color = vbYellow

with

Worksheets(1) ' if the active sheet is something
'other than the 1st worksheet
rg1.Interior.Color = vbYellow

Hope that helps.

--
Cheers,
Michelle
"Anyone who says he can see through women is missing a lot." Groucho Marx


"Roger Converse" wrote:

I have the following and am receiving a run time error 1004. Application
defined or Object Defined error.

What am I doing incorrectly?

Worksheets(1).Activate
If CheckBox1.Value = True Then
Set rg1 = Range("A17:F17")
Sheets(1).Range("rg1").Interior.Color = vbYellow
Else

I am trying to select the cells from A17 - F17 and highlight them yellow.

Thank you,
Roger


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 310
Default Range Question

Oops... I just noticed that you activated the first worksheet above your if/
else statement. In that case you only need...

rg1.Interior.Color = vbYellow

--
Cheers,
Michelle
"Anyone who says he can see through women is missing a lot." Groucho Marx


"Roger Converse" wrote:

I have the following and am receiving a run time error 1004. Application
defined or Object Defined error.

What am I doing incorrectly?

Worksheets(1).Activate
If CheckBox1.Value = True Then
Set rg1 = Range("A17:F17")
Sheets(1).Range("rg1").Interior.Color = vbYellow
Else

I am trying to select the cells from A17 - F17 and highlight them yellow.

Thank you,
Roger


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
Range Question Peter[_8_] Excel Discussion (Misc queries) 3 December 11th 07 02:37 AM
Range Name question Barb Reinhardt Excel Programming 2 November 3rd 06 08:29 PM
Range Question / error 1004: method Range of object Worksheet has failed Paul Excel Programming 3 April 7th 05 02:56 PM
Range question mnewnam Excel Programming 0 October 28th 04 06:51 PM
Range.Formula and Range question using Excel Automation [email protected] Excel Programming 0 September 19th 03 04:53 AM


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