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

Hi, i'm trying to define a range with variables so I can search down a page
and produce graphs till an empty cell is found so it stops the loop but i'm
getting a "run time error '1004': Application-defined or object-defined
error".

My code so far;

Sub Produce_Cum_Graph()
'
' Produce a cumulative graph
' Macro recorded 30/03/04 by Ric
'
'
' Select sheet from where data is to be used
Sheets("cum_data").Select

' define variables
Start = 2 ' Used for row 2
SRow = 1
SCloumn = 3
ERow = 5
EColumn = 39
t1 = Cells(Start, 1).Value ' Contract Name
t2 = Cells(Start, 2).Value ' Contract Number

With Worksheets("cum_data")
Set MyRange = Range(Cells(SRow, SColumn), Cells(ERow, EColumn))
' Slecet range
End With

TheTitle = t2 & " " & "-" & " " & t1 ' Adds Contract Number & space
& - & space & Contract name together
Fname = t2 ' This will be filename of Graph
Call cum_graph ("MyRange", TheTitle", "Fname")

End Sub

cum_graph is a recorded Macro of creating a graph.
MyRange is interposed instead of an actual cell reference in cum_graph.
TheTitle is interposed instead of the typed title while creating the graph.

The error appears at line "Set MyRange..."

Am I going about this in totaly the wrong way to generate a range?

Ric


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Defining a Range

Just glanced at it, but try

With Worksheets("cum_data")
Set MyRange = .Range(.Cells(SRow, SColumn), .Cells(ERow, EColumn))
' Slecet range
End With


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ric" <richard.cravenatbaesystems.com wrote in message
...
Hi, i'm trying to define a range with variables so I can search down a

page
and produce graphs till an empty cell is found so it stops the loop but

i'm
getting a "run time error '1004': Application-defined or object-defined
error".

My code so far;

Sub Produce_Cum_Graph()
'
' Produce a cumulative graph
' Macro recorded 30/03/04 by Ric
'
'
' Select sheet from where data is to be used
Sheets("cum_data").Select

' define variables
Start = 2 ' Used for row 2
SRow = 1
SCloumn = 3
ERow = 5
EColumn = 39
t1 = Cells(Start, 1).Value ' Contract Name
t2 = Cells(Start, 2).Value ' Contract Number

With Worksheets("cum_data")
Set MyRange = Range(Cells(SRow, SColumn), Cells(ERow, EColumn))
' Slecet range
End With

TheTitle = t2 & " " & "-" & " " & t1 ' Adds Contract Number &

space
& - & space & Contract name together
Fname = t2 ' This will be filename of Graph
Call cum_graph ("MyRange", TheTitle", "Fname")

End Sub

cum_graph is a recorded Macro of creating a graph.
MyRange is interposed instead of an actual cell reference in cum_graph.
TheTitle is interposed instead of the typed title while creating the

graph.

The error appears at line "Set MyRange..."

Am I going about this in totaly the wrong way to generate a range?

Ric




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Defining a Range

I've tried that from the help file already bob but i've tried it again
anyway. I still get the same error message as before. The variables in ()
show the correct values while I go through line by line but when i hover the
mouse over "MyRange" it shows "empty" as the value. I just don't think it
will accept the way i've put it together to make a Range.

("C1:AM5") is the range I am looking to call but how could I increment that
in a loop if next t1=true (it would have a range reference of ("C6:AM10")
for next )

Regards

Ric

"Bob Phillips" wrote in message
...
Just glanced at it, but try

With Worksheets("cum_data")
Set MyRange = .Range(.Cells(SRow, SColumn), .Cells(ERow, EColumn))
' Slecet range
End With


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ric" <richard.cravenatbaesystems.com wrote in message
...
Hi, i'm trying to define a range with variables so I can search down a

page
and produce graphs till an empty cell is found so it stops the loop but

i'm
getting a "run time error '1004': Application-defined or object-defined
error".

My code so far;

Sub Produce_Cum_Graph()
'
' Produce a cumulative graph
' Macro recorded 30/03/04 by Ric
'
'
' Select sheet from where data is to be used
Sheets("cum_data").Select

' define variables
Start = 2 ' Used for row 2
SRow = 1
SCloumn = 3
ERow = 5
EColumn = 39
t1 = Cells(Start, 1).Value ' Contract Name
t2 = Cells(Start, 2).Value ' Contract Number

With Worksheets("cum_data")
Set MyRange = Range(Cells(SRow, SColumn), Cells(ERow, EColumn))
' Slecet range
End With

TheTitle = t2 & " " & "-" & " " & t1 ' Adds Contract Number &

space
& - & space & Contract name together
Fname = t2 ' This will be filename of Graph
Call cum_graph ("MyRange", TheTitle", "Fname")

End Sub

cum_graph is a recorded Macro of creating a graph.
MyRange is interposed instead of an actual cell reference in cum_graph.
TheTitle is interposed instead of the typed title while creating the

graph.

The error appears at line "Set MyRange..."

Am I going about this in totaly the wrong way to generate a range?

Ric






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Defining a Range

Ric,

It is all down to a simple typo.

SCloumn = 3

and then use

Set MyRange = .Range(.Cells(SRow, SColumn), .Cells(ERow, EColumn))

not they are not the same, so sColumn is empty when you come to use it.

You should put Option Explicit at the top of your code, and this would force
you to declare your variables, and then these sort of errors would be caught
for you


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ric" <richard.cravenatbaesystems.com wrote in message
...
I've tried that from the help file already bob but i've tried it again
anyway. I still get the same error message as before. The variables in ()
show the correct values while I go through line by line but when i hover

the
mouse over "MyRange" it shows "empty" as the value. I just don't think it
will accept the way i've put it together to make a Range.

("C1:AM5") is the range I am looking to call but how could I increment

that
in a loop if next t1=true (it would have a range reference of ("C6:AM10")
for next )

Regards

Ric

"Bob Phillips" wrote in message
...
Just glanced at it, but try

With Worksheets("cum_data")
Set MyRange = .Range(.Cells(SRow, SColumn), .Cells(ERow,

EColumn))
' Slecet range
End With


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ric" <richard.cravenatbaesystems.com wrote in message
...
Hi, i'm trying to define a range with variables so I can search down a

page
and produce graphs till an empty cell is found so it stops the loop

but
i'm
getting a "run time error '1004': Application-defined or

object-defined
error".

My code so far;

Sub Produce_Cum_Graph()
'
' Produce a cumulative graph
' Macro recorded 30/03/04 by Ric
'
'
' Select sheet from where data is to be used
Sheets("cum_data").Select

' define variables
Start = 2 ' Used for row 2
SRow = 1
SCloumn = 3
ERow = 5
EColumn = 39
t1 = Cells(Start, 1).Value ' Contract Name
t2 = Cells(Start, 2).Value ' Contract Number

With Worksheets("cum_data")
Set MyRange = Range(Cells(SRow, SColumn), Cells(ERow,

EColumn))
' Slecet range
End With

TheTitle = t2 & " " & "-" & " " & t1 ' Adds Contract Number &

space
& - & space & Contract name together
Fname = t2 ' This will be filename of Graph
Call cum_graph ("MyRange", TheTitle", "Fname")

End Sub

cum_graph is a recorded Macro of creating a graph.
MyRange is interposed instead of an actual cell reference in

cum_graph.
TheTitle is interposed instead of the typed title while creating the

graph.

The error appears at line "Set MyRange..."

Am I going about this in totaly the wrong way to generate a range?

Ric








  #5   Report Post  
Posted to microsoft.public.excel.programming
ric ric is offline
external usenet poster
 
Posts: 11
Default Defining a Range

Yeah bob I noticed that one myself after posting, but thanks. It now runs
past that line but MyRange still equals "Empty".

Still getting error 1004 but with "method 'Range' of object '_Global'
Failed" message instead when it comes to select the range in the graph
section.

Ric

"Bob Phillips" wrote in message
...
Ric,

It is all down to a simple typo.

SCloumn = 3

and then use

Set MyRange = .Range(.Cells(SRow, SColumn), .Cells(ERow, EColumn))

not they are not the same, so sColumn is empty when you come to use it.

You should put Option Explicit at the top of your code, and this would

force
you to declare your variables, and then these sort of errors would be

caught
for you


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ric" <richard.cravenatbaesystems.com wrote in message
...
I've tried that from the help file already bob but i've tried it again
anyway. I still get the same error message as before. The variables in

()
show the correct values while I go through line by line but when i hover

the
mouse over "MyRange" it shows "empty" as the value. I just don't think

it
will accept the way i've put it together to make a Range.

("C1:AM5") is the range I am looking to call but how could I increment

that
in a loop if next t1=true (it would have a range reference of

("C6:AM10")
for next )

Regards

Ric

"Bob Phillips" wrote in message
...
Just glanced at it, but try

With Worksheets("cum_data")
Set MyRange = .Range(.Cells(SRow, SColumn), .Cells(ERow,

EColumn))
' Slecet range
End With


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ric" <richard.cravenatbaesystems.com wrote in message
...
Hi, i'm trying to define a range with variables so I can search down

a
page
and produce graphs till an empty cell is found so it stops the loop

but
i'm
getting a "run time error '1004': Application-defined or

object-defined
error".

My code so far;

Sub Produce_Cum_Graph()
'
' Produce a cumulative graph
' Macro recorded 30/03/04 by Ric
'
'
' Select sheet from where data is to be used
Sheets("cum_data").Select

' define variables
Start = 2 ' Used for row 2
SRow = 1
SCloumn = 3
ERow = 5
EColumn = 39
t1 = Cells(Start, 1).Value ' Contract Name
t2 = Cells(Start, 2).Value ' Contract Number

With Worksheets("cum_data")
Set MyRange = Range(Cells(SRow, SColumn), Cells(ERow,

EColumn))
' Slecet range
End With

TheTitle = t2 & " " & "-" & " " & t1 ' Adds Contract Number

&
space
& - & space & Contract name together
Fname = t2 ' This will be filename of Graph
Call cum_graph ("MyRange", TheTitle", "Fname")

End Sub

cum_graph is a recorded Macro of creating a graph.
MyRange is interposed instead of an actual cell reference in

cum_graph.
TheTitle is interposed instead of the typed title while creating the
graph.

The error appears at line "Set MyRange..."

Am I going about this in totaly the wrong way to generate a range?

Ric












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
Defining Range Name anshu[_2_] Excel Discussion (Misc queries) 2 July 22nd 07 07:30 AM
Defining a range Don Excel Worksheet Functions 1 February 25th 05 03:54 PM
Defining range Edgar[_3_] Excel Programming 2 February 17th 04 02:24 PM
Defining a range Matt Excel Programming 3 January 23rd 04 03:21 PM
Defining Range MAB[_5_] Excel Programming 2 September 15th 03 02:48 PM


All times are GMT +1. The time now is 03:18 AM.

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"