+ Reply to Thread
Results 1 to 4 of 4

Worksheet change event to move values up over non-contiguous ranges (remove spaces)

  1. #1
    Forum Contributor
    Join Date
    10-08-2013
    Location
    London
    MS-Off Ver
    365
    Posts
    138

    Worksheet change event to move values up over non-contiguous ranges (remove spaces)

    Hi All,

    I have two non-contiguous ranges that I would like to have a worksheet change event move values up as they are entered into cells within the range. The net result should be to move values up to ensure that the cell below the last used cell is the next cell to be populated. I have attached an example of what I mean including before and after examples. I have tried several ways to find the last used cell and move values up based on that if the cell above is blank but have had no joy in getting it to work.

    The code should concentrate on values in columns C & N and move adjacent values in columns D & O at the same time. This is to ensure any values pasted into cell pairs at the same time are moved at the same time. As soon as a value is moved, the row in columns C or N where the value has been relocated should be selected. I'm not sure if a worksheet change event applies to every key stroke or after enter has been pressed? If the code applied after the full value had been entered this would be great but understand if this is not possible. I do not need to sort the values at the same time, just move them up.

    Alternatively, if this is not possible or is too difficult, I would be happy if the values could be reshuffled on the click of a command button. I have included this in the sample sheet just in case!

    Could anyone please assist? The example is an exact copy of the format the full worksheet uses so was hoping that any VBA applied would be utilising this.

    Many thanks,
    Attached Files Attached Files
    Dave C

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Worksheet change event to move values up over non-contiguous ranges (remove spaces)

    Hi,

    Is it allowed to get rid of columns D,E & F so that the item & location are in columns C&D much like columns N&O are next to each other. In fact make the left hand table of cells the same 5 column range as the N:R columns.

    A sorting solution would be simpler but that assumes the Items are numerics. Is that the case or is this just a simple example of your actual data.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Worksheet change event to move values up over non-contiguous ranges (remove spaces)

    Code for button

    Please Login or Register  to view this content.
    Kind regards
    Leo

  4. #4
    Forum Contributor
    Join Date
    10-08-2013
    Location
    London
    MS-Off Ver
    365
    Posts
    138

    Re: Worksheet change event to move values up over non-contiguous ranges (remove spaces)

    Hi Richard, thanks for your input. One of my criteria is that the sheet must be utilised as it is. I thought of the sorting solution too, but I do not want to change the order a user inputs their data.

    Hi Leo, thank you for your great solution. This has made my life a lot easier and I'm very grateful!

    Many thanks,

+ 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] Repeating Worksheet Change Event on Different Ranges
    By Tanooki in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-22-2014, 09:43 PM
  2. [SOLVED] Worksheet change event applying to multiple ranges
    By MaddyG in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-29-2013, 12:04 PM
  3. [SOLVED] Worksheet change event to Formulate Cells for multiple Ranges
    By trickyricky in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-15-2012, 02:38 PM
  4. [SOLVED] TTest with values in non-contiguous ranges
    By Domenic in forum Excel Formulas & Functions
    Replies: 35
    Last Post: 09-06-2005, 07:05 PM
  5. [SOLVED] TTest with values in non-contiguous ranges
    By Kristina in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  6. [SOLVED] TTest with values in non-contiguous ranges
    By Kristina in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM
  7. How to Remove Non-Contiguous Columns from Worksheet
    By sjane in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-06-2005, 02:06 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