+ Reply to Thread
Results 1 to 3 of 3

Move the content of cell based on a value

  1. #1
    Registered User
    Join Date
    03-01-2018
    Location
    India
    MS-Off Ver
    2010
    Posts
    33

    Move the content of cell based on a value

    Hi All,

    Can you please with below? I'm moving the content of cells manually now. Is there any VBA or formula to do this?
    This is the input. I need to content to move row wise based on the level number. If it is level 1, content has to move one row to the right. If level is 2, the content has to move two rows right and so on.
    1.JPG

    Output required:
    2.JPG

    Please let me know.

    Thank you.

  2. #2
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,496

    Re: Move the content of cell based on a value

    That will need VBA. You might want to ask a moderator to move the post to the VBA forum. A formula could be written that would give you the output required section but 39761ACE would appear in Level 1 AND the formula would also need to be in Levels 2 through 5 but just returning blanks. And the formula wouldn't remove the values in the number column.

    for example, this in (wherever the cell is below level 1 is) =IF(RIGHT(C$1,1)*1=$A2,$B2,"") then dragged right and down will populate the values in those cells.
    BUT those numbers will still remain in the Number column and unless you then copy and paste special values, if you delete the numbers by hand the output will disappear.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  3. #3
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Move the content of cell based on a value

    This code should work assuming:

    Levels are in column A (A2:A?)
    Numbers are in column B (B2:B?)
    Headers 'Level 1' thru 'Level 5' are in C1:G1
    (all of these ranges can be adjusted/expanded, of course)

    This doesn't use a myriad of cut/paste, just value assignment, hence the last line of code clears the values from column B to get the output as you've shown
    Please Login or Register  to view this content.
    The code doesn't actually reference the headers for the Levels, it's simply adding 2 to the value in column A to put the data in the 'correct' column to the right. (e.g. value 1 + 2 = 3, with 3rd column being C; value 5 + 2 = 7, with 7th column being G)
    Last edited by Paul; 02-19-2020 at 03:41 PM.

+ 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. Move row(s) to a new workbook based on cell content
    By CMason87 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-06-2018, 12:35 PM
  2. [SOLVED] How to automatically move Line(Shapes) based on cells content?
    By hmgrts in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 03-12-2013, 01:30 AM
  3. VBA Code- Move/Split cell content based on ","
    By Langer101 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 12-19-2012, 11:37 AM
  4. move rows based on cell content and add header
    By reggie1000 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-26-2009, 03:05 AM
  5. move cells based on partial-content.
    By jimmyyang in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-21-2008, 02:21 AM
  6. Delete & Move columns based on Heading content
    By carsto in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-02-2007, 10:09 AM
  7. Replies: 2
    Last Post: 12-19-2006, 10:50 PM

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