+ Reply to Thread
Results 1 to 4 of 4

Create VBA Range for multiple groups of cell ranges

  1. #1
    Registered User
    Join Date
    07-26-2013
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Create VBA Range for multiple groups of cell ranges

    I'm not sure if what I'm trying to do is possible, but I would like to be able to create a range in vba for multiple groups of cells that is dynamic (the range will change if I add or remove rows). Currently, I have header rows with dependent rows beneath them (I can add/remove these dependent content rows). In a column to the right in each header row, I have a formula to return the range of cells within these dependent rows (e.g. K20:K31, K33:K40, K42:K99, K101:K105, K107:K116, K118:K131). I also have a cell where I concatenate all these individual ranges (K20:K31,K33:K40,K42:K99,K101:K105,K107:K116,K118:K131).

    What I'd like to do is create a code where I can set these values as a range (end-result being that I clear the contents of these cells if criteria are met. I'm using the following code with no success:

    Please Login or Register  to view this content.
    OTA Checklist!B16 is the cell that has the concatenated ranges.

  2. #2
    Registered User
    Join Date
    07-26-2013
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Create VBA Range for multiple groups of cell ranges

    Okay, after more searching (Google's my best friend), I found a solution which appears to work:

    Please Login or Register  to view this content.
    If anyone knows a better way than this, I'd love to know. Thanks.

  3. #3
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Create VBA Range for multiple groups of cell ranges

    As you can see , your code is not available
    If solved remember to mark Thread as solved

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Create VBA Range for multiple groups of cell ranges

    There may be a couple of alternatives depending on the nature of your data.

    The .SpecialCells method can select all cells with formulas in column K.
    Range("K:K").SpecialCells(xlCellTypeFormulas).Select
    This could also select cells with constants (text and\or numbers or blanks)

    Or you could create a Named Range and then reference the named range in your code e.g.;
    For Each Cell In Range("MyRange")
    The named range will change as you add\delete rows. Do a web search for something like Excel Named Range tutorial.

    The best way to do it very much depends on the nature of your data.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

+ 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. Replies: 2
    Last Post: 05-31-2013, 12:01 AM
  2. [SOLVED] Create macro that searches multiple named ranges and returns name of the range with data
    By mechant in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-15-2013, 01:04 AM
  3. [SOLVED] Create multiple ranges based on an index of values that are also used as range names
    By Apog in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-05-2013, 12:48 PM
  4. Loop Through Range and Create Strings Based on Groups
    By P5C768 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-11-2012, 07:24 AM
  5. Copy range of cell data to range of cells arranged by groups
    By Wayne Makeeff in forum Excel General
    Replies: 0
    Last Post: 01-27-2005, 12:17 AM

Tags for this Thread

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