Page 1 of 2 1 2 LastLast
Results 1 to 10 of 17

Thread: Vbscript help needed!

  1. #1
    Seeker Daghs's Avatar
    Join Date
    Apr 2021
    Posts
    13
    Articles
    0
    Excel Version
    Excel10

    Vbscript help needed!



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hi,

    I have a very limited knowledge about vbscript so I am not sure what is possible in vbscript and what is not but I want if my problem could be solved with vbscript code .

    The word column I'm using here is just for explaining as we use in excel sheet I dont know how to mention it in .csv way!
    The problem I am having is something like this!

    I have a file named "list.csv" & a folder named "WORKERS".
    Now this folder has .csv files which are generated on daily basis & has just 2 rows of daily wages details.

    In "WORKERS" folder file names are listed in list.csv file's first column as serials.

    Now what I want is, if "WORKERS" folder file name matches in the first column's row of list.csv "the entire 2nd row of that file to be pasted in list.csv file's 3rd column of matched row"

    For example,

    List.csv has 2nd row

    = "AL,Alex Chris,"

    in which AL is a serial & now "WORKERS" folder has matched file named AL.csv with serial so the 2nd row of file AL.csv

    = "800,100,200,0,0,80,0"

    should be copied in list.csv at the end of the matched row which becomes

    = "AL,Alex Chris,800,100,200,0,0,80,0"

    If for any reason the file is not generated row must be shown "NOT AVAILABLE"

    = "AL,Alex Chris,NOT AVAILABLE"

    The way I see it. It's just an act of locating and merging two lines but if somebody has to do it for couple of hundred times daily it becomes an awful job!

    I've also attached zip for file and folder. I hope I could get some help here!

    Thanks.
    Attached Files Attached Files

  2. #2
    Seeker Daghs's Avatar
    Join Date
    Apr 2021
    Posts
    13
    Articles
    0
    Excel Version
    Excel10
    No response,
    I'm hoping anybody could suggest anything!

  3. #3
    Administrator AliGW's Avatar
    Join Date
    Nov 2015
    Location
    Ipswich, Suffolk, England
    Posts
    1,718
    Articles
    0
    Excel Version
    MS365 Sub (Insider) Win11
    It's not been 12 hours yet since you first posted AND it's a Sunday! Please be patient. Any help you get will be for free and in our own time. If this is really urgent, you may want to consider looking as a 24/7 paid service, which we don't have here.
    Ali
    Enthusiastic self-taught user of MS Excel!

  4. #4
    Seeker Daghs's Avatar
    Join Date
    Apr 2021
    Posts
    13
    Articles
    0
    Excel Version
    Excel10

    Smile

    My apologies for impatience I didn't think of holiday,
    I just looked at the views & thought of no response!

  5. #5
    Super Moderator p45cal's Avatar
    Join Date
    Dec 2012
    Posts
    2,023
    Articles
    0
    Excel Version
    365
    In the attached is a Power Query suggestion.
    on Sheet1 there's a small table where you can update the necessary.
    The current data is where things were in my setup, it'll be wrong for you for sure.
    You can update these values manually or you can click the buttons to let you navigate to them in a friendlier way. The buttons run a couple of short macros, and these are the ONLY reason you might want to enable macros.
    Otherwise, go to the Table1 sheet, right-click somewhere in the table there and choose Refresh. (Alternatively, you can click the Refresh All icon in the Queries & Connections section of the Data tab of the ribbon.)

    This table has a query behind it, so to get your file, copy the table (or minus the headers) and paste as values on another sheet or workbook and save as a csv file.
    Last edited by p45cal; 2021-04-26 at 01:23 AM.

  6. #6
    Seeker Daghs's Avatar
    Join Date
    Apr 2021
    Posts
    13
    Articles
    0
    Excel Version
    Excel10
    Hi,
    Thanks for the suggestion I did as you mentioned but I am keep getting an error
    "Initialization of the data source failed.
    Check the database server or contact your database administrator. Make sure the external database is available, and then try the operation again. If you see this message again, create a new data source to connect to the database"

    Could you please suggest what am I doing wrong?

  7. #7
    Super Moderator p45cal's Avatar
    Join Date
    Dec 2012
    Posts
    2,023
    Articles
    0
    Excel Version
    365
    Could you try again with this attached file; I found a hard-coded reference to a folder which I've taken out now.
    Attached Files Attached Files

  8. #8
    Seeker Daghs's Avatar
    Join Date
    Apr 2021
    Posts
    13
    Articles
    0
    Excel Version
    Excel10
    I'm sorry but same error again!
    I'm using excel2010 this isn't a problem? right!

  9. #9
    Super Moderator p45cal's Avatar
    Join Date
    Dec 2012
    Posts
    2,023
    Articles
    0
    Excel Version
    365
    Try to get it installed:
    How To Install Excel 2010 Power Query | MyExcelOnline
    https://www.myexcelonline.com/blog/i...ry-excel-2010/
    Download Microsoft Power Query for Excel from Official Microsoft Download Center
    https://www.microsoft.com/en-us/down...6-64140f90750a

  10. #10
    Seeker Daghs's Avatar
    Join Date
    Apr 2021
    Posts
    13
    Articles
    0
    Excel Version
    Excel10
    Hi,
    Sorry for the delay but I upgraded to excel 2016!
    Now here after using navigation buttons when I right click on refresh it gives an error!
    "[Expression.Error] The csv.Document parameter 'Columns' is invalid." and I don't have any clue what is that!

    Actually I'm new to this power query & my vba programming is also at the beginning level so I hope you wouldn't mind me asking.
    Thanks,

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •