+ Reply to Thread
Results 1 to 13 of 13

Help with Resize function to select non-adjacent columns

  1. #1
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Help with Resize function to select non-adjacent columns

    Hi,

    I am trying to modify a VBA code in order to get the output from the code pasted in columns N, R and V instead of the original, and adjacent, columns N, O and P in a worksheet named “ows”.

    There are a few lines in the code that I need help to modify:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    I am quite inexperienced with VBA and tried the modifications below, but got Syntax Error:


    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Any suggestions?

    Regards,
    Marbleking

  2. #2
    Forum Contributor
    Join Date
    05-10-2012
    Location
    Paris, France
    MS-Off Ver
    2016/365
    Posts
    123

    Re: Help with Resize function to select non-adjacent columns

    Hi Marbleking,

    the correct syntax would be
    Please Login or Register  to view this content.
    But, to my knowledge, it is impossible on discontinuous range

    What works is
    Please Login or Register  to view this content.
    Cordialy
    If you are satisfied with my answer, please add reputation

  3. #3
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Help with Resize function to select non-adjacent columns

    Thanks, BrianM45.

    I’ll test your suggestion as soon as I have the opportunity. It looks like the latter piece of code would affect the columns inbetween N, R and V, though.

    Perhaps there exists an alternative to using the Resize function that would work on discontinuous ranges.

    Regards

  4. #4
    Forum Contributor
    Join Date
    05-10-2012
    Location
    Paris, France
    MS-Off Ver
    2016/365
    Posts
    123

    Re: Help with Resize function to select non-adjacent columns

    Hi,

    Can you tell us why not to use :
    Please Login or Register  to view this content.
    Regards

  5. #5
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Help with Resize function to select non-adjacent columns

    Hi,

    I can probably use that when the equality is "", but not for these two lines:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Regards

  6. #6
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Help with Resize function to select non-adjacent columns

    Hi,

    I found out I could use the Union function, like this:

    Please Login or Register  to view this content.
    Regards

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

    Re: Help with Resize function to select non-adjacent columns

    I don't think what you posted will work correctly. What exactly is arr3 ?

  8. #8
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Help with Resize function to select non-adjacent columns

    You may be right. It seemed to identify the desired ranges, but I got type mismatch errors when I ran the code. Please have a look at this thread for the complete code:

    "Make VBR independent of column order in data table, output results in non-adjacent columns"

    Regards,
    Marbleking

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

    Re: Help with Resize function to select non-adjacent columns

    You did not answer my question (which is not addressed in your posted code)... what exactly is arr3 (describe it in detail)?

  10. #10
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Help with Resize function to select non-adjacent columns

    arr3 is a variable in the last of several steps for organising output of text data in a worksheet. I am not able to describe it in more detail. I wrote formulas with Excel functions using a lot of helper columns at first, but got that logic "translated" to VBA by someone else. The complete code is included in the thread "Make VBR independent of column order in data table, output results in non-adjacent columns" along with some broader questions, if you'd have a look.

    Regards,
    Marbleking

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

    Re: Help with Resize function to select non-adjacent columns

    So your arr, arr3 and so forth are each single text strings and not arrays then (most people tend to use arr for arrays)? Meaning you are trying to put the same text value in multiple cells?
    Last edited by Rick Rothstein; 08-29-2020 at 02:21 PM.

  12. #12
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Help with Resize function to select non-adjacent columns

    These may be arrays as you say, I am a bit on shaky ground when it comes to VBA, but yes, a lot of the text values are put in multiple cells. The code organises hierarchical data consisting of three levels, and there are a one to many relationship between each of the two first levels and the succeeding level.

  13. #13
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Help with Resize function to select non-adjacent columns

    Hi,

    I have attached a workbook that includes the code and some data in this thread, so it is easier to see how it works:

    "Make VBR independent of column order in data table, output results in non-adjacent columns"

+ 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: 5
    Last Post: 02-29-2020, 08:45 AM
  2. [SOLVED] Remove adjacent duplicates and select corresponding values from other columns
    By shaaquille in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-19-2019, 04:27 AM
  3. [SOLVED] When attempting to select a single column, I highlight adjacent columns as well...help!
    By afterdinnerspeaker in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-15-2019, 03:45 PM
  4. Replies: 2
    Last Post: 05-01-2014, 08:04 PM
  5. [SOLVED] Issue w/ Current Region, Select 3 Columns of Data without selecting adjacent columns
    By EnigmaMatter in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-10-2014, 02:57 PM
  6. select range using offset or resize property
    By longhorn23 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-07-2010, 06:16 PM
  7. Resize Range without Select
    By achidsey in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-13-2005, 03:06 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