+ Reply to Thread
Results 1 to 7 of 7

Range references not working

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Range references not working

    Can anyone explain why this piece of code doesn't work?
    Please Login or Register  to view this content.
    I do get a value for a and I am trying to test to make sure the Cylsize value ends up in the right place.
    I just get an error, whichever way I designate the range
    John

  2. #2
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Range references not working

    What is the value of a and where are you trying to put "Z"?

    Please Login or Register  to view this content.
    A Range can take two cells (giving the upper left and bottom right points of a range), but I don't think it can take just one.

    Without knowing the value of a, you might try:

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: Range references not working

    Hi stevenM,
    Thanks for your interest. a is an integer with a value of a row number. What I am trying to do is to edit and add to a large table. Me.tbRow gives the row number of the row I am working on,"Z" ,(or Me.CbCylSize, plus others) is the edited data that needs to be written into row a. I had first used the offset notation of the rem'd line, but that didn't work, so I then tried the cells notation that also fails.
    I hope this explains things more
    John

  4. #4
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Range references not working

    Have you stepped through the code? What went wrong? Toggle a Breakpoint on the line:

    Please Login or Register  to view this content.
    Then run you code.

    What is the value of 'a' when your code stops on this line?

  5. #5
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Range references not working

    Steven's code is correct. if you assume a = 3 then the version you had
    Please Login or Register  to view this content.
    means:
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  6. #6
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Range references not working

    Assuming that the variable 'a' refers to a row (and assuming that these statements are inside a "With Worksheet ... End With"), then the following statements all mean the same thing:

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: Range references not working

    Thanks for all your comments.
    It became clear that I had missunderstood the meaning of .Cells(a,1). Once I got that straight all fell into place.
    Once again thank you
    John

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1