+ Reply to Thread
Results 1 to 10 of 10

Complex Loop Pipe-Delimited Data Export

  1. #1
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Complex Loop Pipe-Delimited Data Export

    Hello,

    I have a complicated excel sheet I am trying to pull data from and export in a pipe delimited format required for some software to understand. I have attached 5 lines from an example sheet Please _HELP.csv but the total number of rows will vary every time. I have also attached an example of what the end result needs to be formatted as Format_Example.txt with my attempt at what code would produce the correct value. The values between the "||" in quotes are my code attempts. I don't know how to create a loop that will work to convert these sheets to the pipe delimited format required. We have to manually do this for every sheet we get as of now. I would greatly appreciate help with figuring this out and can answer any questions if I wasn't clear enough with what I am trying to accomplish.

    Thank you VERY much

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Complex Loop Pipe-Delimited Data Export

    Copy to a module.

    Import your CSV file, then run this.

    Please Login or Register  to view this content.
    David
    (*) Reputation points appreciated.

  3. #3
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Complex Loop Pipe-Delimited Data Export

    Impressively concise! I have a couple other things I would like the code to do and I am trying to fully understand your loop and how it works to see if I can make the modifications. Your code did exactly what I asked and I am truly impressed with how simply you achieved the end result with such a short script. Should I change the thread to answered now or wait so I can post some additional questions this next week or so if I am unable to figure things out on my own?

  4. #4
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Complex Loop Pipe-Delimited Data Export

    I'm glad the result satisfied your query. I wasn't sure I was on the right track.

    Should I change the thread ...
    If you think your question is relevant to this thread, then ask away.

  5. #5
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Complex Loop Pipe-Delimited Data Export

    The software is unable to process the file with the blank cells. Some cells in the H column on, don't have a value and therefore leaves the space between the pipes blank. I am not sure where to add an if statement to go to the next value when the cell in columns H to the last column are blank. I m not sure if I am explaining this clearly. Basically, if the referenced cell is blank then the SO and the LD lines aren't written to the file and it goes on to the next column and continues the loop.

  6. #6
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Complex Loop Pipe-Delimited Data Export

    I think I may have got it. Would you mind checking if what I did is correct and if it is the simplest method? I tried to just increment by 1 if the column value was blank.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Complex Loop Pipe-Delimited Data Export

    My code begins to skip the blank cells but doesn't finish skipping them. My code addition isn't complete.

    My code stops removing the blank cells when there are two consecutive empty cells in a single row.
    Last edited by cnash52; 01-27-2016 at 11:27 AM. Reason: New info

  8. #8
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Complex Loop Pipe-Delimited Data Export

    I would do it this way, because when you start messing with the next counter, you can get unexpected results.
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    09-13-2012
    Location
    Maine
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Complex Loop Pipe-Delimited Data Export

    I cant seem to get this script modification to work appropriately. I am trying to set a variable "Offset" based on whether column E is increasing or decreasing. If it is increasing than the second CStr term in C$ is -H:1+.Cells(1,B). If decreasing the term is H:1-.Cells(1,B). I also added in a round feature and needed to change values from meters to feet. Can you look over what I did to ma any suggestions and please help me figure out how to get my "Offset issue resolved.
    Please Login or Register  to view this content.

  10. #10
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Complex Loop Pipe-Delimited Data Export

    I don't think you can have a leading minus in the first cell.
    Before
    Offset = -.Cells(1, 8) + .Cells(1, B)
    After
    Offset = .Cells(1, 8) + .Cells(1, B)

    Or is that suppose to be
    Offset = 1 -.Cells(1, 8) + .Cells(1, B)
    Last edited by Tinbendr; 01-28-2016 at 04:29 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. Excel Field Data pipe delimited with many fields inside
    By ginjack in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-14-2015, 04:35 PM
  2. Converting Pipe Delimited Data String into Seperate columns using VBA Macro
    By mikey42979 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-20-2014, 03:15 PM
  3. [SOLVED] Pipe delimited vs comma delimited problem
    By theletterh in forum Excel General
    Replies: 4
    Last Post: 01-23-2013, 07:27 PM
  4. [SOLVED] Concatenating cells where one contains Pipe delimited data
    By Acedge in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-04-2012, 12:25 PM
  5. Export worksheets from multiple workbooks into pipe delimited txts
    By anshul03 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-30-2012, 05:16 AM
  6. Export Multiple Tabs to Pipe Delimited Txt
    By Machie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-03-2010, 08:32 PM
  7. How can I convert tab delimited files to pipe delimited?
    By Jeremy Town in forum Excel General
    Replies: 1
    Last Post: 01-23-2006, 11:10 AM

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