+ Reply to Thread
Results 1 to 5 of 5

Can I put multiple columns into 1 set range?

  1. #1
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Can I put multiple columns into 1 set range?

    Hi guys,

    I have a database with a lot of columns with data. I get the first column I want and stick it into x, then the last column I want and stick it into Y. Z is the last row of the sheet.
    Then I have the following code :

    Please Login or Register  to view this content.
    Which gives me the following :
    $G$8:$G$34254,$J$8:$J$34254,$M$8:$M$34254,$P$8:$P$34254,$S$8:$S$34254,$V$8:$V$34254,$Y$8:$Y$34254,$AB$8:$AB$34254,$AE$8:$AE$34254,$AH$8:$AH$34254,$AK$8:$AK$34254,$AN$8:$AN$34254,$AQ$8:$AQ$34254,$AT$8:$AT$34254,$AW$8:$AW$34254,$AZ$8:$AZ$34254,$BC$8:$BC$34254,$BF$8:$BF$34254,$BI$8:$BI$34254,$BL$8:$BL$34254,$BO$8:$BO$34254,$BR$8:$BR$34254,$BU$8:$BU$34254,$BX$8:$BX$34254,$CA$8:$CA$34254,$CD$8:$CD$34254,$CG$8:$CG$34254,$CJ$8:$CJ$34254,$CM$8:$CM$34254,$CP$8:$CP$34254,$CS$8:$CS$34254

    I want to put this into one range, so I can subtotal them all together - I try to set the range as :
    Please Login or Register  to view this content.
    but it errors out without a clear error code.
    What am I doing wrong?

    EDIT
    If I would just set "ytdcols" to "ytdcols = "$G$8:$G$34254,$J$8:$J$34254,$M$8:$M$34254,$P$8:$P$34254,$S$8:$S$34254,$V$8:$V$34254,$Y$8:$Y$34254,$AB$8:$AB$34254"" then it works fine... Is there a limit to the number of arguments / cells you can put in a range?
    Last edited by JasperD; 08-07-2014 at 10:39 AM.
    Please click the * below if this helps

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Can I put multiple columns into 1 set range?

    UNION(range1, range 2,etc)
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Can I put multiple columns into 1 set range?

    Hi Nathansav, thanks for your reply! How would I incorporate this into my code?

  4. #4
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Can I put multiple columns into 1 set range?

    Please Login or Register  to view this content.
    not in excel, so cant test, and heading home now.

  5. #5
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Can I put multiple columns into 1 set range?

    Thank you Nathansav.

    After one small tweak, it works like a charm!
    Much appreciated!

+ 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] Transpose 2 Columns into Multiple Columns per Range of Cells
    By ub3rm0nk3y in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-31-2013, 02:30 PM
  2. Replies: 2
    Last Post: 03-05-2013, 03:07 PM
  3. Replies: 0
    Last Post: 08-14-2012, 01:18 PM
  4. Filter for date range across multiple columns and multiple worksheets
    By Pugface in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-02-2011, 05:30 AM
  5. Sum of Product Multiple Columns/Multiple Sheets, Indefinite Range
    By endurion in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-12-2007, 05:33 PM

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