Results 1 to 6 of 6

Thread: Whats the syntax for R1C1 notation ?

  1. #1

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Question 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

    I've got the following

    VB Code:
    1. 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:
    1. objexcel.Range(tmpAddress) = iGrid.CellText(iRow, 15)

    but I'm getting "Method 'Range' of object'_Application' failed" errors

    Can someone point out the error of my ways please.

  2. #2

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    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.

  3. #3
    Addicted Member
    Join Date
    Jan 2006
    Location
    Montreal, Canada
    Posts
    152

    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:
    1. NewStoreRow = Chr(64 + StoreRow)
    2.  
    3. tmpAddress = NewStoreRow & StoreCol


    But will not work if your column is higher than Z
    Last edited by billhuard; Jul 21st, 2006 at 12:08 PM.

  4. #4
    Junior Member littlepd's Avatar
    Join Date
    Jun 2006
    Location
    Lewisville, TX
    Posts
    28

    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 & "]"
    I used to have a handle on life, but it broke.

  5. #5
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: Whats the syntax for R1C1 notation ?

    If you want to reference a cell, why use a range?

    VB Code:
    1. objexcel.cells(storerow,storecol)  = iGrid.CellText(iRow, 15)


    zaza
    I use VB 6, VB.Net 2003 and Office 2010



    Code:
    Excel Graphing | Excel Timer | Excel Tips and Tricks | Add controls in Office | Data tables in Excel | Gaussian random number distribution (VB6/VBA,VB.Net) | Coordinates, Vectors and 3D volumes

  6. #6

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width