Posts by la99123

    I am not too sure why the workbook is repeated as another forum user had helped to put the code together.

    The date portion is determined by when the report is generated by a 3rd party. The files to be cleansed may be produced weekly/monthly so the date will change accordingly.

    I was originally thinking i could create a cell which the user could enter the file name into. For example the user will select one of the four potential file names from a dropdown, enter a date and then i would concatenate the data to arrive at the exact file name in a cell e.g. E27. The vba would then pull the file name based on the contents of said cell. ( i could not find a way to do this after scouring google and other forums).

    Hi All,

    I am trying to get some VBA code to pick up a file name that may be variable.

    The code below is designed to remove line items present in a sheet in workbook 1 from a sheet in workbook 2 (shout out to Mumps!). I have highlighted in the code below which is the variable file path.

    The file path will be one of 4 file names with the date always being variable.

    E.g. workbook 1, workbook 2, workbook 3, workbook 4. But the 4 file names may on occasion be a bit more complex e.g. workbook_workbook_&_workbook_18052021.

    Is it possible to achieve this in VBA? Or is it better that i create 4 workbooks and use each of them depending on which workbook i am trying to remove line items from?

    Any help would be much appreciated! :thumbup:

    Hi Mumps, hope you're having a good evening and thank you very much for the response. :) apologies for the late reply, i had some trouble with my connection. I have managed to get on and have attached the desensitised workbooks. I have included some information in there to reflect what i am trying to achieve. hopefully it makes sense but i can answer any queries if not! Thank you for offering to help, it means a lot. :thumbup:

    Hi guys,

    I hope you're well and safe. I am trying to create a macro to delete line items in another workbook but i am a total novice. After hours of research I am still struggling badly to the point where i feel useless. I was sincerely hoping some good people on this forum could help save me from throwing my laptop out of the window. ||

    What i am trying to achieve;

    Workbook 1 (2 x sheets)

    • Sheet 1 - has a cell where the user inputs the file name of Workbook 2 which is to have line items deleted from it e.g. "Workbook 2 22-04-2021" which will be closed. Also has a button to run the macro.
    • Sheet 2 - contains data in many columns but column A will be the deciding factor of which rows should be deleted in Workbook 2 - Sheet 1.

    Workbook 2 (1x sheet)

    - contains the data and the line items which are to be deleted if present in Workbook 1, Sheet 2.

    Any help from the geniuses on here would be much appreciated and i would be forever grateful! X