Whats the syntax for R1C1 notation ?
I'm sure I am being very very dull, but I can't seem to set an R1C1 style address via code :confused:
I've got the following
VB Code:
tmpAddress = "R" & StoreRow & "C" & StoreCol
The value of tmpAddress is currently reading as "R7C1", and is defined as a string. Hmmm ... is THAT my problem .... defining it as a string ?
I'm trying to use it thus :
VB Code:
objexcel.Range(tmpAddress) = iGrid.CellText(iRow, 15)
but I'm getting "Method 'Range' of object'_Application' failed" errors :confused:
Can someone point out the error of my ways please.
Re: Whats the syntax for R1C1 notation ?
I've also got "ReferenceStyle = xlR1C1" already set by the way, in case anyone asks.
Sorry should have mentioned that.
Re: Whats the syntax for R1C1 notation ?
Had this problem before and I never found a way to solve the R1C1
but I did the following to solve my problem.
VB Code:
NewStoreRow = Chr(64 + StoreRow)
tmpAddress = NewStoreRow & StoreCol
But will not work if your column is higher than Z
Re: Whats the syntax for R1C1 notation ?
I've never used R1C1 referencing in this fashion. I've only used it in creating a string for a "FormulaR1C1 = " type of assignment statement.
That being said, this is the way the R1C1 string needs to look the way I use it:
R[7]C[1].
So I would try something like this:
Code:
tmpAddress = "R[" & StoreRow & "]C[" & StoreCol & "]"
Re: Whats the syntax for R1C1 notation ?
If you want to reference a cell, why use a range?
VB Code:
objexcel.cells(storerow,storecol) = iGrid.CellText(iRow, 15)
zaza
Re: Whats the syntax for R1C1 notation ?
Zaza thats exactly what I needed. It didn't even occur to me to not use a rabge object. See ... I knew asking the question would be worthwhile :)
Thanks a lot :)
Incidentally ... it was the omission of the square brackets as suggested by littlepd that was causing me problems late Friday afternoon.
Thanks all.