+ Reply to Thread
Results 1 to 7 of 7

Variable in Range...

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Variable in Range...

    Hello:

    I am using below code :

    Please Login or Register  to view this content.
    I need code : Set r = Range("A138", Range("A" & Rows.Count).End(xlUp)) to be changed so that A138 becomes variable and pick the value as SRange as defined above.

    Let me know if you have any questions.
    Thanks.

    Riz

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Variable in Range...

    If SRange is a positive number then you could use

    Please Login or Register  to view this content.
    However, how do you want to handle these situations.

    1) B1 contains a string or a bad number (e.g. -12) or an error value (e.g. #DIV/0)

    2) sRange is larger than Cells(Rows.Count,1).End(xlup).Row
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

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

    Re: Variable in Range...

    Try
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  4. #4
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: Variable in Range...

    Hello YasserKhalil:

    I have tried your solution but it gives error as attached...
    Attached Images Attached Images

  5. #5
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: Variable in Range...

    Hello mikerickson:

    I get mismatch error with your solution.
    Please let me know if you have any questions.
    Thanks.

    R

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Variable in Range...

    What is the value of SRange when that error occurs?

  7. #7
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: Variable in Range...

    Hello mikericson and Yasser:

    Your solution works.
    Thanks a lot..

    Riz

+ 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] Set range address as variable and then clear the cell via the variable
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-13-2016, 02:23 PM
  2. [SOLVED] Setting a variable range with a variable sheet name. Hmm?
    By starcraftbud in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-11-2013, 11:46 AM
  3. [SOLVED] creating a variable range in VBA to be copied to variable sheets
    By adamNBU in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-29-2013, 06:20 PM
  4. Copy variable range from variable workbook to variable range on current workbook
    By Locster79 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-09-2013, 10:37 AM
  5. vlookup with variable range and variable array size
    By chaslie in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-16-2013, 02:37 PM
  6. [SOLVED] Copy/Paste Values from Variable Range to Corresponding Variable Range
    By Cpetersoc in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-14-2012, 08:20 AM
  7. Variable- how can i change the range in the row below into a variable
    By OLEG_V in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-27-2010, 04:19 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