#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 161
Default error

I get a run time error when I run this procedure. It's probably something
simple but I can't figure out why it won't run. What am I doing wrong?
This is the procedu

Sub enteritem()
Dim a(8) As Range
Dim tcell As Range
Dim x As Integer
Dim xcell As Range
Dim drwno As Integer



'a(1) = draw
drwno = ActiveCell.EntireRow.Cells(2).Value
MsgBox (drwno)
drw = ActiveSheet.Range("currentdraw").Value
Set xcell = Range(drw & "itemno").Offset(drwno, 0)
For x = 3 To 8
Set tcell = Range(xcell.Offset(0, x))
Next
End Sub

thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default error

In the line "drw = ActiveSheet.Range("currentdraw").Value" you use drw which
isn't declared as a variable

Sam

"ranswert" wrote:

I get a run time error when I run this procedure. It's probably something
simple but I can't figure out why it won't run. What am I doing wrong?
This is the procedu

Sub enteritem()
Dim a(8) As Range
Dim tcell As Range
Dim x As Integer
Dim xcell As Range
Dim drwno As Integer



'a(1) = draw
drwno = ActiveCell.EntireRow.Cells(2).Value
MsgBox (drwno)
drw = ActiveSheet.Range("currentdraw").Value
Set xcell = Range(drw & "itemno").Offset(drwno, 0)
For x = 3 To 8
Set tcell = Range(xcell.Offset(0, x))
Next
End Sub

thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 161
Default error

I added
dim drw as string
and I still get a

'run time error '1004
method 'range of object'_global failed'

and this line is highlighted in yellow

Set tcell = Range(xcell.Offset(0, x))

"Sam Wilson" wrote:

In the line "drw = ActiveSheet.Range("currentdraw").Value" you use drw which
isn't declared as a variable

Sam

"ranswert" wrote:

I get a run time error when I run this procedure. It's probably something
simple but I can't figure out why it won't run. What am I doing wrong?
This is the procedu

Sub enteritem()
Dim a(8) As Range
Dim tcell As Range
Dim x As Integer
Dim xcell As Range
Dim drwno As Integer



'a(1) = draw
drwno = ActiveCell.EntireRow.Cells(2).Value
MsgBox (drwno)
drw = ActiveSheet.Range("currentdraw").Value
Set xcell = Range(drw & "itemno").Offset(drwno, 0)
For x = 3 To 8
Set tcell = Range(xcell.Offset(0, x))
Next
End Sub

thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default error

Ah, OK.

You've declared xcell as a range, so the code you need to set tcell is just

set tcell = xcell.offset(0,x)


"ranswert" wrote:

I added
dim drw as string
and I still get a

'run time error '1004
method 'range of object'_global failed'

and this line is highlighted in yellow

Set tcell = Range(xcell.Offset(0, x))

"Sam Wilson" wrote:

In the line "drw = ActiveSheet.Range("currentdraw").Value" you use drw which
isn't declared as a variable

Sam

"ranswert" wrote:

I get a run time error when I run this procedure. It's probably something
simple but I can't figure out why it won't run. What am I doing wrong?
This is the procedu

Sub enteritem()
Dim a(8) As Range
Dim tcell As Range
Dim x As Integer
Dim xcell As Range
Dim drwno As Integer



'a(1) = draw
drwno = ActiveCell.EntireRow.Cells(2).Value
MsgBox (drwno)
drw = ActiveSheet.Range("currentdraw").Value
Set xcell = Range(drw & "itemno").Offset(drwno, 0)
For x = 3 To 8
Set tcell = Range(xcell.Offset(0, x))
Next
End Sub

thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 161
Default error

Thank You

"Sam Wilson" wrote:

Ah, OK.

You've declared xcell as a range, so the code you need to set tcell is just

set tcell = xcell.offset(0,x)


"ranswert" wrote:

I added
dim drw as string
and I still get a

'run time error '1004
method 'range of object'_global failed'

and this line is highlighted in yellow

Set tcell = Range(xcell.Offset(0, x))

"Sam Wilson" wrote:

In the line "drw = ActiveSheet.Range("currentdraw").Value" you use drw which
isn't declared as a variable

Sam

"ranswert" wrote:

I get a run time error when I run this procedure. It's probably something
simple but I can't figure out why it won't run. What am I doing wrong?
This is the procedu

Sub enteritem()
Dim a(8) As Range
Dim tcell As Range
Dim x As Integer
Dim xcell As Range
Dim drwno As Integer



'a(1) = draw
drwno = ActiveCell.EntireRow.Cells(2).Value
MsgBox (drwno)
drw = ActiveSheet.Range("currentdraw").Value
Set xcell = Range(drw & "itemno").Offset(drwno, 0)
For x = 3 To 8
Set tcell = Range(xcell.Offset(0, x))
Next
End Sub

thanks



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default error

I think you'll have to be more explicit.

What value is in drwno?
What is CurrentDraw--a single cell or lots of cells?
What is/are the value/s in currentdraw

xcell is already a range.
Does xcell.Offset(0, x) really have something in it that looks like an address

When you do that for/next loop, what do you expect to happen?
You're really only doing:
Set tcell = Range(xcell.Offset(0, 8))

(or did you skinny down the code for testing?)



ranswert wrote:

I get a run time error when I run this procedure. It's probably something
simple but I can't figure out why it won't run. What am I doing wrong?
This is the procedu

Sub enteritem()
Dim a(8) As Range
Dim tcell As Range
Dim x As Integer
Dim xcell As Range
Dim drwno As Integer

'a(1) = draw
drwno = ActiveCell.EntireRow.Cells(2).Value
MsgBox (drwno)
drw = ActiveSheet.Range("currentdraw").Value
Set xcell = Range(drw & "itemno").Offset(drwno, 0)
For x = 3 To 8
Set tcell = Range(xcell.Offset(0, x))
Next
End Sub

thanks


--

Dave Peterson
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
run time error 1004 general odbc error excel 2003 vba Mentos Excel Programming 5 January 24th 11 02:56 PM
Error Handling - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
Form Err.Raise error not trapped by entry procedure error handler [email protected] Excel Programming 1 February 8th 06 10:19 AM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Automation Error, Unknown Error. Error value - 440 Neo[_2_] Excel Programming 0 May 29th 04 05:26 AM


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