+ Reply to Thread
Results 1 to 11 of 11

basic conversion of cell address to a range

  1. #1
    Registered User
    Join Date
    12-28-2019
    Location
    oman
    MS-Off Ver
    1010
    Posts
    7

    basic conversion of cell address to a range

    Hi guys,

    Do you know how i can convert this cell address to a range so that i can access the cells' properties and methods :

    Set foundRng = Sheet11.Range("b1:b27").Find(Sheet10.ComboBox1.Text)
    Set addCell = Worksheets("Speaking Total").Range(foundRng.Address(RowAbsolute:=False))

    foundRng.Address // i attained this address from the "Speaking Total" worksheet after it matched a value in a combobox.

    I just want to be able to access the "foundRng.Address" like a normal cell range.

    Thanks

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: basic conversion of cell address to a range

    Hello marlon1_1,

    Every cell on a worksheet is a Range Object. Objects contain the properties, methods, and events in the Object's Class. The Find Method of a Range Object will return either a Range Object if successful or the special system Object Nothing if the search fails.

    The code below assigns the result of the Range Find method to the Range Object Variable foundRng. This will either return a Range Object (worksheet cell) or Nothing provided the object variable foundRng has been declared in a Dim statement either as a Range or Variant.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    12-28-2019
    Location
    oman
    MS-Off Ver
    1010
    Posts
    7

    Re: basic conversion of cell address to a range

    Hi Leith,

    A snake would have bit me. Thanks for the proverb and for the answer.

    Cheers,
    Marlon

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: basic conversion of cell address to a range

    Hello Marlon,

    You're welcome. I am happy to help.

  5. #5
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: basic conversion of cell address to a range

    Quote Originally Posted by marlon1_1 View Post
    . . .
    Please Login or Register  to view this content.
    . . .
    Is Sheet11 the same as Worksheets("Speaking Total")? There's never a good reason to use aliases like Sheet11, always better to make worksheet references explicit by name or (less frequently) by index number.

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Exclamation


    Nope ! Better is to use the worksheet codename rather than its name or its index only if
    the worksheet is within the same workbook where is located the procedure …

  7. #7
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: basic conversion of cell address to a range

    Quote Originally Posted by Marc L View Post
    Nope ! Better is to use the worksheet codename rather than its name or its index . . .
    How much VBA code do you maintain? Where I work, there's a standard which prohibits the use of codenames.

    Curios: is there some advantage to codenames? Certainly not clarity. Time performance since no lookup is needed?

  8. #8
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: basic conversion of cell address to a range

    Quote Originally Posted by hrlngrv View Post
    is there some advantage to codenames?
    One might be that you can use them directly without having to make them the argument to the Sheets object. Of course, the downside is you cannot iterate them in a loop like with sheet names as the argument to the Sheets object.


    Quote Originally Posted by hrlngrv View Post
    Certainly not clarity.
    If you are willing to forego spaces, you can give them a more useful name by renaming a sheet's CodeName via the Properties window.
    Last edited by Rick Rothstein; 01-19-2020 at 05:23 AM.

  9. #9
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: basic conversion of cell address to a range

    Quote Originally Posted by hrlngrv View Post
    How much VBA code do you maintain? Where I work, there's a standard which prohibits the use of codenames.

    Curios: is there some advantage to codenames? Certainly not clarity. Time performance since no lookup is needed?
    The standard of your work likes superfluous maintenance and does very not rule the rest of the world ‼

    For an obvious reason : when an user may change the sheet name or the sheets order,
    your code does not work anymore and you have to maintain it, mine still works at it is, no maintenance needed !
    And as sheet codenames can be amended for clarity by any clever VBA coder …

  10. #10
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    Quote Originally Posted by Rick Rothstein View Post
    Of course, the downside is you cannot iterate them in a loop like with sheet names as the argument to the Sheets object.
    Rick,

    codenames should be iterated via the project components, like when you want to access to an external codename …

  11. #11
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: basic conversion of cell address to a range

    Quote Originally Posted by Marc L View Post
    . . . The standard of your work likes superfluous maintenance and does very not rule the rest of the world ‼ . . .
    1st debatable, 2nd granted.

    . . . when an user may change the sheet name or the sheets order, . . .
    Workbook protection prevents renaming worksheets. Since formulas calling INDIRECT with references to worksheets other than the one containing the formulas would also be adversely affected by arbitrarily renamed worksheets, generally a good idea to protect workbooks. As for worksheet order, if worksheets can't be renamed, how could Worksheets("some_name") be rendered invalid? If worksheet foo originally appeared as the 1st in a workbook, would moving it to the middle or end affect Worksheet("foo")?

    Granted codenames can be changed, but Sheet11 (Sheet follwed by a positive integer) isn't descriptive.
    Last edited by hrlngrv; 01-19-2020 at 10:01 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. IP address conversion formula
    By naeemdotcom in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 06-11-2022, 07:08 PM
  2. Bulk IP address and Subnet mask to CIDR conversion
    By Ni99leS404 in forum Excel General
    Replies: 1
    Last Post: 07-17-2019, 12:43 AM
  3. Help with basic math problem(proportion conversion). Pls
    By juntjoo in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 11-09-2018, 07:16 PM
  4. Getting chart range from range address contained in a cell
    By Journeyman3000 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-03-2013, 08:10 PM
  5. Excel VBA conversion OpenOffice Basic
    By the.white.hole in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-08-2011, 07:50 AM
  6. Dynamic cell address resolution in visual basic application?
    By John Carter in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-26-2006, 11:50 AM

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