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

I am trying to name a range based on a user's selection from a list
box so the procedure can then copy that range to another range. I
don't want the user to see the program moving between sheets, so I am
avoiding using "select". Below is my code so far. I am getting an
"object required" error on the "Set Scenario..." line. Can someone
please explain what I'm doing wrong here? Thanks.

JG Scott




Sub ActivateScenario()

Dim RngToCopy As Range
Dim LastRow As Long
Dim LastCol As Long
Dim ScenarioToShow As Range
Dim Scenarios As Worksheet
Dim Names As ListBox


If Range("CountList").Value = 0 Then

MsgBox ("There are no saved scenarios. To create one, click on
the ""Save Scenario"" button.")

Exit Sub

End If


NameScenarioList

frmScenarios.Show

ActiveWorkbook.Names.Add Name:="ActiveScenario", RefersToR1C1:= _
"=Scenarios!R2C1"


Set ScenarioToShow = Range("ActiveScenario").Value


With Sheets("Scenarios")

LastRow = .Range("ScenarioToShow").Offset(99, 0)
LastCol = .Range("ScenarioToShow").Offset(0, 2)
Set RngToCopy = .Range("ScenarioToShow", .Cells(LastRow,
LastCol))

End With



End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Object Error

Set ScenarioToShow = Range("ActiveScenario").Value

should be

Set ScenarioToShow = Range("ActiveScenario")

with no value on the end.

--
Regards,
Tom Ogilvy


"JG Scott" wrote:

I am trying to name a range based on a user's selection from a list
box so the procedure can then copy that range to another range. I
don't want the user to see the program moving between sheets, so I am
avoiding using "select". Below is my code so far. I am getting an
"object required" error on the "Set Scenario..." line. Can someone
please explain what I'm doing wrong here? Thanks.

JG Scott




Sub ActivateScenario()

Dim RngToCopy As Range
Dim LastRow As Long
Dim LastCol As Long
Dim ScenarioToShow As Range
Dim Scenarios As Worksheet
Dim Names As ListBox


If Range("CountList").Value = 0 Then

MsgBox ("There are no saved scenarios. To create one, click on
the ""Save Scenario"" button.")

Exit Sub

End If


NameScenarioList

frmScenarios.Show

ActiveWorkbook.Names.Add Name:="ActiveScenario", RefersToR1C1:= _
"=Scenarios!R2C1"


Set ScenarioToShow = Range("ActiveScenario").Value


With Sheets("Scenarios")

LastRow = .Range("ScenarioToShow").Offset(99, 0)
LastCol = .Range("ScenarioToShow").Offset(0, 2)
Set RngToCopy = .Range("ScenarioToShow", .Cells(LastRow,
LastCol))

End With



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
runtime error '1004' application or object defined error. Please help deej Excel Programming 0 August 1st 07 09:26 AM
Object Variable Not Set Error on Selection object Jean Excel Worksheet Functions 3 July 24th 06 06:45 PM
Error 1004, Application-definded or object-defined error Mirco Wilhelm[_2_] Excel Programming 9 January 7th 06 04:56 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM


All times are GMT +1. The time now is 01:54 AM.

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"