Urgent HELP!!!!! VB in MS Excel

I have a data file in Excel which contains a lot of information for different hospitals. I want to create separate Excel files which contains the information specific to one hospital - I don't want hospitals to see data from other hospitals. Ideally I would like one click that will generate the reports for me

I am not sure how to go about this. I have some VB code but for business objects and it doesn't work in excel.

Please help!!!!



Answer this question

Urgent HELP!!!!! VB in MS Excel

  • Jayaram Krishnaswamy

    hello nhsfreak,

    There is an article on my blog that will let you select the rows you want from your sheet very easily. You'd be able to select all records where hospital = X and then copy them into another sheet. The title might be 'how to parse large amounts of data in Excel efficiently'. Let me know if you have any problems with it.

    To do what you want you'd need to run this code in a loop. The steps would be something along the lines of, for each hospital, create new sheet, select the hospital data from your original, copy to the new sheet, save, next hospital.

    Hope that helps...



  • foocc

    How is the sheet organized
    Couldn't you loop through it and just move the data

    A helpful tip :
    Record macros for everything you want to.
    IE: Move Data, Create New sheet, Rename Sheet


    Hope that helps


  • Coder4Christ

    You need to modify the recorded code such that there's a variable that counts the number of entry. While Loop can be used.

    Email me, I'd like to help you with this. Please send me your email address at 639209590012@chikkatxt.com, I'll get your email thru my cell phone. I don't want to post my email address here. :) I'll be replying you after the weekend...

    MUSIC_AT_ULAN


  • Mehmet Metin Altuntas

    The problem is with recording a macro is that every month the data for each hospital changes. Example: For Jan Hospital X would have two lines of data but then for Feb same Hospital X would have five lines of data.

    Example Data:

    Hospital Patient Type HRG No of Patients

    X Elective A01 15

    X Day Case E52 72

    Y Elective S22 10

    Y Emergency H41 16

    Z Emergency C65 54

    So I would want three files - one for Hospital X containing just the first two lines of data, one for Hospital Y containing the fourth and fifth lines of data and then one for hospital Z containing the last line of data.

    Every month the number of lines for each hospital can change and every month more hospitals could be added.

    Hope this clarifies want I want to do


  • laboremus

    You can also try using Pivot Report, or maybe a combination of VBA (Macro) and Pivot. Doing so lessens the coding.
  • cgn

    I have a very large number of excel files that contain data I want to upload into a excel spreadsheet. I currently use a macro to upload data from four cells within the excel file into the spreadsheet. The problem is that I have to click two buttons one time each for each excel file to upload into the spreadsheet. This is a very time consuming task when I have over 2000 excel files to upload.

  • Urgent HELP!!!!! VB in MS Excel