+ Reply to Thread
Results 1 to 15 of 15

VBA, Macro, or formula to move data based off of value

  1. #1
    Registered User
    Join Date
    02-13-2014
    Location
    USA
    MS-Off Ver
    Office 2016
    Posts
    10

    VBA, Macro, or formula to move data based off of value

    I have a question that is hard to frame. I have some flight logbook data that I need consolidated on to a single line. The "SEQ NUMBER" column has a value of 1-5. If there are 3 flights with SEQ NUMBERS of 1,2,&3 they are all the same flight, but have different modes of flight. The only line I can keep is line one so I want to move values greater than zero from the lines below (2&3) for the different modes of flight, up to SEQ 1. I have attached a sample of data as an example. I either need to write a formula to accomplish this and then write VBA to delete the SEQ NUMBERS after one or a VBA module that will move the data to SEQ 1. If anyone has a reference or similar example I don't mind researching and finding a solution but I cannot find a starting point or the framework for the method to do it. Any suggestions would be appreciated.
    Attached Files Attached Files

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: VBA, Macro, or formula to move data based off of value

    Hi,
    To make it easier for others to understand I suggest you add a section with the desired end result.
    I've read it several times but ...
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    02-13-2014
    Location
    USA
    MS-Off Ver
    Office 2016
    Posts
    10

    Post Re: VBA, Macro, or formula to move data based off of value

    Thanks for pointing out the obvious I should have thought of that. Below is a picture of what I am trying to do. The way the system logs the time is it splits one flight into three different legs if the mode of flight is different (Night, weather, etc). All three legs would equal the total of the flight. The system that I have to feed only accepts a single entry . I hope this helps. The bottom single line would be the end result in this example.
    example.PNG

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: VBA, Macro, or formula to move data based off of value

    Does this mean that you only want a sequence for where there is a 1, 2 AND 3? ignore the rest?

    What about the TIME_USERx ?

    You want it an the same sheet and delete the others or on a new sheet?

  5. #5
    Registered User
    Join Date
    02-13-2014
    Location
    USA
    MS-Off Ver
    Office 2016
    Posts
    10

    Re: VBA, Macro, or formula to move data based off of value

    I am not good at this. Thanks for the patience. Flights with only one sequence number are good without any modifications. Flights with multiple sequence numbers are the same flight but the modes are broke out in separate lines (Night, Weather, etc.). I need to consolidate them back into 1 sequence number. When it is complete I want a list as below.
    example2.PNG
    I am currently doing this manually and then I have a vba module to save the results as a csv in a separate file. The modes of flight are highlighted in the attached screen shot. The columns in blue do not end up getting saved in the new csv. Just the columns with red headers. The new csv would look like the rows starting in row 22 of the screen shot with the headers as well. I hope this explains a little better and thanks for your reply and patience.

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: VBA, Macro, or formula to move data based off of value

    Clear, I don't think that will be a problem.
    If I understand you correctly you already have a module to export those lines as csv file.
    I'll work on in and hope to get back you asap

  7. #7
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: VBA, Macro, or formula to move data based off of value

    Try this.
    Run the macro by pressing the image
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    02-13-2014
    Location
    USA
    MS-Off Ver
    Office 2016
    Posts
    10

    Re: VBA, Macro, or formula to move data based off of value

    Thanks for your time! I will give that a shot and let you know how it works. Thanks again for the effort!

  9. #9
    Registered User
    Join Date
    02-13-2014
    Location
    USA
    MS-Off Ver
    Office 2016
    Posts
    10

    Re: VBA, Macro, or formula to move data based off of value

    Keebellah,

    That is absolutely perfect and I learned some valuable insight in looking at how you accomplished what I was trying to do. I can't thank you enough for your assistance and knowledge.

  10. #10
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: VBA, Macro, or formula to move data based off of value

    I'm sorry I did not add any comments to the code explaining my train of thought, just holler if you need some clarification

  11. #11
    Registered User
    Join Date
    02-13-2014
    Location
    USA
    MS-Off Ver
    Office 2016
    Posts
    10

    Re: VBA, Macro, or formula to move data based off of value

    I'm working on optimizing so it doesn't take so long to run. When I run the code with 3400+ rows it takes about 20 minutes. The cells that are being copied are derived from formulas (the example just had values to make it easier). What would be your recommendation be to copy over just values to the new sheet (no formulas, formatting etc.). Thanks!

  12. #12
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: VBA, Macro, or formula to move data based off of value

    I agree that values is better than formulas.
    Another thing to speed if up is to turn calculation off before you start and then back on again.
    I use both macros before and after a routine:

    Please Login or Register  to view this content.
    Try and see if it speeds things up.

    Please Login or Register  to view this content.

  13. #13
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: VBA, Macro, or formula to move data based off of value

    I've implemented it here copying the cells and pasting only the values; I also added a progress update on the Statusbar
    You will probably have to check the cell format at destination
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    02-13-2014
    Location
    USA
    MS-Off Ver
    Office 2016
    Posts
    10

    Re: VBA, Macro, or formula to move data based off of value

    Thanks again. As expected it works exactly as I needed it to. I was close on the "xlpastevalues" but my inexperience surfaced and my syntax was incorrect. Thanks again

  15. #15
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: VBA, Macro, or formula to move data based off of value

    And did it process faster?

+ 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] Macro to move data from one worksheet to another based off of criteria;
    By KLiving in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-17-2015, 12:41 PM
  2. excel 2007 macro to move data to a new column on the same row based on specific text
    By charmallan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-15-2014, 06:29 PM
  3. [SOLVED] Macro to Move Rows to New Worksheets Based on Criteria & Then HIDE & Move Back
    By abro0821 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-22-2014, 04:00 PM
  4. [SOLVED] Macro Needed - Move data to worksheet based on criteria
    By sharpyoungb in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-10-2014, 11:42 AM
  5. Excel 2007. Macro to move data based on dropdown list.
    By D_N_L in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-10-2012, 10:52 AM
  6. Macro to Move Data Between Sheets Based on Columns
    By MSmithson in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-24-2011, 09:21 PM
  7. [SOLVED] Macro to move data to different column based on data in another co
    By malycom in forum Excel General
    Replies: 3
    Last Post: 08-02-2005, 03:05 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