+ Reply to Thread
Results 1 to 8 of 8

Column deletion using column numbers as user input (how to change syntax of ranges)

  1. #1
    Forum Contributor
    Join Date
    03-01-2019
    Location
    New York, New York
    MS-Off Ver
    Office 2016 for Mac
    Posts
    125

    Column deletion using column numbers as user input (how to change syntax of ranges)

    Hi all. I am using the following code to input column numbers and delete those columns. This deletion differs for each client, hence the macro. I am currently trying to code out the column numbers for the user instructions but am running into a difficulty. The current syntax allows me to list a single column number followed by a comma. How would I change the code below to allow for ranges? (e.g. instead of 1, 2, 3, 4...I would like to use 1-4). One of my deletion ranges for client A is columns 84-128. It would be too much for the user to input every single column number. NOTE: I would like the syntax to allow for single columns as well as ranges.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Column deletion using column numbers as user input (how to change syntax of ranges)

    If your columns will always be contiguous, then you can use the Alpha designation for the columns instead of the numbers and then something like this:
    Please Login or Register  to view this content.
    You would only need an array if the columns are noncontiguous.
    Last edited by JLGWhiz; 04-22-2019 at 07:39 PM.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,527

    Re: Column deletion using column numbers as user input (how to change syntax of ranges)

    Hi Ianmacros,

    Try this (though initially on a copy of your data as the results cannot be undone if they're not as expected):

    Please Login or Register  to view this content.
    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  4. #4
    Forum Contributor
    Join Date
    03-01-2019
    Location
    New York, New York
    MS-Off Ver
    Office 2016 for Mac
    Posts
    125

    Re: Column deletion using column numbers as user input (how to change syntax of ranges)

    @JLGWhiz yes the columns are sometimes non-contiguous. Could you give specifics about how I would use an array? Thanks so much.

  5. #5
    Forum Contributor
    Join Date
    03-01-2019
    Location
    New York, New York
    MS-Off Ver
    Office 2016 for Mac
    Posts
    125

    Re: Column deletion using column numbers as user input (how to change syntax of ranges)

    @Trebor76 I will give this a try! Thank you.

  6. #6
    Forum Contributor
    Join Date
    03-01-2019
    Location
    New York, New York
    MS-Off Ver
    Office 2016 for Mac
    Posts
    125

    Re: Column deletion using column numbers as user input (how to change syntax of ranges)

    Thank you both! Robert's fix worked. I appreciate the input and support. VBA is exciting to learn but I am really only a few months in to coding.

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,560

    Re: Column deletion using column numbers as user input (how to change syntax of ranges)

    Different method.
    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,527

    Re: Column deletion using column numbers as user input (how to change syntax of ranges)

    Thank you both! Robert's fix worked. I appreciate the input and support.
    Thanks for letting us know and you're welcome. Thanks also for marking the thread as solved and for the rep

    Robert

+ 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] Sum of one column, but the numbers being calculated could change based on another column
    By ciresuark in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-10-2016, 07:38 PM
  2. Change ranges used in VBA code with user input
    By ptuzzolo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2015, 07:14 PM
  3. Replies: 4
    Last Post: 05-08-2014, 09:43 PM
  4. Using text box input to lookup number and replace based on user input into new column
    By harl3y412 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-28-2011, 03:15 PM
  5. Excel 2007 : Change column of numbers into ranges
    By michele867 in forum Excel General
    Replies: 0
    Last Post: 02-17-2011, 01:53 PM
  6. Input by many user but no deletion rights
    By eight8 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-06-2008, 07:28 AM
  7. How can I change column numbers back to column letters?
    By Space Elf in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-02-2006, 05:40 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