+ Reply to Thread
Results 1 to 17 of 17

Compact approach to refer to range

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Compact approach to refer to range

    Hello everyone
    I know this question is so simple and I can do that in several ways
    How can I refer to the range O2:O & or by the column number as variable?
    In fact, I am trying to search for the most compact way to refer to that range using the "col" variable which equals to 15
    I have used this line
    Please Login or Register  to view this content.
    But this includes the whole column but I need only from the second row to the last row
    lrData is the last row as variable
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Compact approach to refer to range

    How about
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Compact approach to refer to range

    Thanks a lot
    I don't need to use the column letter "O" at all. I would rely on the column number variable "col" which equals to 15

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Compact approach to refer to range

    In that case
    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Compact approach to refer to range

    Thanks a lot. This what I did exactly and I though there may be more compact approach. Thanks a lot for sharing.

  6. #6
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Compact approach to refer to range

    How about this ?

    Please Login or Register  to view this content.
    If I was able to help, you can thank me by clicking the * Add Reputation under my user name

  7. #7
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Compact approach to refer to range

    That's better nankw83. Thanks a lot

  8. #8
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Compact approach to refer to range

    Glad to help

  9. #9
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Compact approach to refer to range

    Another option
    Please Login or Register  to view this content.

  10. #10
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Compact approach to refer to range

    Thanks a lot Fluff. That's great too.

  11. #11
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Compact approach to refer to range

    Last try :D

    Please Login or Register  to view this content.

  12. #12
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Compact approach to refer to range

    Great. Thanks a lot for more suggestions.

  13. #13
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Compact approach to refer to range

    I would use such a fucntion
    Please Login or Register  to view this content.
    I need your opinion: Is that better to create a UDF for such stuff or this would slow down the performance of the code and it is better to use this directly
    I would use a UDF as I need to do such thing for more than 15 times ..
    So my question is creating a UDF is better or not?

  14. #14
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Compact approach to refer to range

    If I was in your situation I wouldn't create such UDF because it is just a single line of code & not many lines of code that has to be repeated. In addition, when debugging the code, it would just jump from your code to the UFD which I don't like. In terms of performance, I am not really sure whether or not it slows the code down but you can create a sample file with a large data & do speed test to confirm it in your machine. Perhaps some more experts will share different opinions
    Last edited by nankw83; 05-19-2020 at 06:00 PM.

  15. #15
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Compact approach to refer to range

    Thanks a lot
    I have another idea which is to loop through the variables that I need to create but I don't know if it possible or not
    Please Login or Register  to view this content.
    But this doesn't create the variables ..How could I create those variables in much easier way?

  16. #16
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Compact approach to refer to range

    You can assign the strings to an array & call it by the array index … Something like below

    Please Login or Register  to view this content.

  17. #17
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Compact approach to refer to range

    Thank you very much for the great help.

+ 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. [SOLVED] How to check if named range not refer to workbook's range?
    By jaryszek in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-27-2019, 07:05 AM
  2. Best approach to get unique items from a range
    By ImranBhatti in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-24-2019, 12:33 PM
  3. [SOLVED] Help for v-lookup approach instead of manually cell linking approach - Excel 2010
    By Mirisage in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-31-2013, 01:32 PM
  4. [SOLVED] Fix range in formula and range refer to other sheet
    By DavidRoger in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-22-2012, 11:51 AM
  5. Replies: 0
    Last Post: 06-25-2012, 03:28 PM
  6. How do I refer a Range to a Cell
    By Mal in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-05-2005, 10:05 PM
  7. Deleting blank rows in a range or another fill approach
    By BigDave in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-03-2005, 11:05 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