View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rowan[_2_] Rowan[_2_] is offline
external usenet poster
 
Posts: 226
Default Object range method runtime error

Neal

I can see two reasons this method may fail. The first is that when using the
cells property with Range you need to specify Cells twice. So your code would
read:

Set zzbranchstdT = tpdmanif.range(cell,cell)

Alternately you could just use the cells property of the sheet. So

Set zzbranchstdT = tpdmanif.cell.

However this still doesn't work for me as VBA doesn't seem to want to accept
the string variable here. Why don't you just use

Set zzbranchstdT = tpdmanif.Cells(endmanifrow + 1, trackcol)

which takes away the need to set and use the cell variable.

Hope this helps
Rowan

"Neal Zimm" wrote:

In my application there are values i want to place in consistently
named cells. The location of these cells can vary by row.
They must appear after the row which has a row number of endmanifrow.

my "developing" code is below.

Things were going fine until i got to the "method" I really
wanted, "try #3" when I got the runtime error.

I suppose I can build a string variable to hold the E6 value,
(try#2) from the endmanifrow and trackcol values,
but I'd prefer not to.

In the module's declarations:
tpdmanif is dim'd as worksheet.
zzbranchstdT is dim'd as object
Any suggestions on how to implement the try#3 method? Thanks.
Neal Z


Sub e_develop()

Call n_AJC_TPD_Common_Values ''' holds the sheet names

If UCase(ActiveSheet.name) < ajc_sheetname And _
UCase(ActiveSheet.name) < tpd_sheetname And ActiveSheet.name <
"Sheet1" Then
MsgBox ActiveSheet.name & " IS INVALID"
Exit Sub
End If

Call zfind_endofmanifest(1, endmanifrow, "test")
If endmanifrow = 0 Then Exit Sub
Call zfind_trackcol(endmanifrow, 4, 50, trackcol, "test")
If trackcol = 0 Then Exit Sub

Set tpdmanif = Sheets(tpd_sheetname)
Set tpdmanif = Sheets("Sheet1") '''test

''' Set zzbranchstdT = tpdmanif.range("E6") ''' try #1, this worked

''' Dim cell: cell = "E6" ''' try#2 lines worked, but not what I
really want
''' Set zzbranchstdT = tpdmanif.range(cell)

''' try #3 THIS IS WHAT I WANT BUT AM GETTING RUNTIME ERROR, METHOD RANGE
OF OBJECT FAILED
Dim cell: cell = "Cells(endmanifrow + 1, trackcol)"
Set zzbranchstdT = tpdmanif.range(cell) ''' THIS IS THE LINE THAT ERROR'D
OUT

''' Set zzrowT = tpdmanif.range(Cells(endmanifrow + 2, trackcol))
''' Set postitT = tpdmanif.range(Cells(endmanifrow + 3, trackcol))

zzbranchstdT = 811 ''' TEST LOADING THE CELL, worked for trys 1 and 2


End Sub
--
Neal Z