+ Reply to Thread
Results 1 to 7 of 7

Push data to the right of a range of cells

  1. #1
    Forum Contributor
    Join Date
    09-07-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    358

    Push data to the right of a range of cells

    Hey,

    I have a large datasheet which has some columns where the data needs to be pushed to the right of a range of cells, the example attached should be clear enough I don't know how to make it easier to understand because it's pretty easy anyway just one of those extremly repetitive tasks if done manually

    See attachment

    Thanks in advance
    - Hyflex
    Attached Files Attached Files
    Last edited by Hyflex; 10-22-2011 at 06:55 PM.

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Push data to the right of a range of cells

    hi, Hyflex, please check attachment, run code "test"
    Attached Files Attached Files

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Push data to the right of a range of cells

    @watersev, that's a great macro. As a general teaching tip to others, be sure to declare the variable type for all the variables:
    Please Login or Register  to view this content.

    Separately, purely as a personal preference for "readability", I'd suggest not using single letter variables, especially not a bunch. Doing it does create some pretty awesome smart-looking code, but novices will really have trouble reading it. Why not indicate in your macros what the variables all do, like you did with "data" and "result" and "row_count"?

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 10-22-2011 at 02:59 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Forum Contributor
    Join Date
    09-07-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    358

    Re: Push data to the right of a range of cells

    I tried to edit it to my liking for my main sheet and I cant get it to work...
    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Push data to the right of a range of cells

    @Hyflex

    Why does DataRange equal to 1 Column: ("AN8:AN" & y)? Can you upload reallife sample workbook (10-15 rows are enough)

    @thanks, Jerry. It's a matter of habbit, I use single letter variables mainly for counters. Otherwise it looks a bit messy.

  6. #6
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Push data to the right of a range of cells

    further down DataRange array
    Please Login or Register  to view this content.
    becomes Data
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    09-07-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    358

    Re: Push data to the right of a range of cells

    Sorry, that was my mistake it seems the edit with the varible delcarations was the main problem + two mistakes in my coded version... the final macro below works perfect.

    Thank you very very much guys

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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