error

R

ranswert

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 procedure:

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
 
S

Sam Wilson

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

Sam
 
R

ranswert

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))
 
S

Sam Wilson

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)
 
D

Dave Peterson

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?)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top