Copy specific worksheets values only to a new workbook

  • I am a vba rookie and have hit a wall.
    Here is the general layout i'm trying to accomplish. I've created a gradebook for a school. Each teacher will have one grade workbook that can contain up to 12 subjects. These subjects are hidden via code unless a class name is entered in a cell on a "menu" page. Each subject has a class grade summary page.


    I'm trying to make macro that will do the following:
    1) determine if a class name has been entered in a certain cell in the menu page
    2) if one has been entered then copy the summary page for that subject into a new workbook (of course only copy values only not formulas)
    3) macro needs to do this for each of the 12 cells in the "menu" and return all the needed summary pages to the same new workbook.


    that file can then be used to report grades to school office.


    Is this possible? the only thing i have gotten to work is to have each summary page copy to its own new workbook and it still has the formulas


    i've searched the forum and cant find any code that will do this even after i edit them to fit my layout.


    please help.

  • Re: Copy specific worksheets values only to a new workbook


    You will have to adjust the workbook and sheet names, and adapt into your code, but something like:


    Code
    With NewWorkbook
        .Sheets("ClassSummary").UsedRange.Value = .Sheets("ClassSummary").UsedRange.Value
    End With
  • Re: Copy specific worksheets values only to a new workbook


    thanks for trying to help dangle but i was unable to get it to work.
    here is what i have so far...


    this code will look at my menu cell to make sure its not blank then copy the first summary page


    so my question is how to i get this to look at multiple cells in the menu and then copy multiple worksheets values only (i'm guessing dangle's code somewhere) to one new workbook?

  • Re: Copy specific worksheets values only to a new workbook


    I don't know if this is really what you are looking for and it would help to see a sample file but here is a possible. Note it saves the "Summary" workbook.


  • Re: Copy specific worksheets values only to a new workbook


    okay dangle your post got me thinking of some other ways to do this it works but it is slow can you think of anyway to speed up the function of this code? (I'm sure this is sloppy code but it does do exactly what i want it to). I'm concerned about the speed of it because it is already slow and I'm only half done. The full code would keep going until it checked for a count of 12 in the counta and copied all 12 sheets.



  • Re: Copy specific worksheets values only to a new workbook


    would it run faster if i divided each show--copy--hide action in to different subs and then reference them in the if counta is 1 then do this, if counta is 2 then do that, etc.?

  • Re: Copy specific worksheets values only to a new workbook


    There may be slightly better ways of doing this, such as using a 'select case' statement rather than multiple 'if' statements and organising the unhiding/hiding of sheets, maybe use some additional subs, but I am not sure that this is your issue if you are saying it is noticeably slow.
    How about:

    Code
    Application.Calculation = xlCalculationManual
    'Your code
    Application.Calculation = xlCalculationAutomatic
  • Re: Copy specific worksheets values only to a new workbook


    sorry for the slow response... I was moving accross the country


    It works great thanks so much.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!