Results 1 to 4 of 4

Thread: [RESOLVED] Simple copy sheet with no formula macro

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2006
    Posts
    45

    Resolved [RESOLVED] Simple copy sheet with no formula macro

    Trying to copy a worksheet to another workbook (got that far)

    However, I only want the values and format of the original worksheet to be copied accross. No formulas.

    Is this doable - I have searched for the last 2 hours on it and can not find any reference.

  2. #2
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Re: Simple copy sheet with no formula macro

    I think you need two pastespecial operations to achieve that.

    Try something like this:
    VB Code:
    1. Sheets("Sheet1").Cells.Copy
    2.     Sheets("Sheet2").Cells.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    3.     Sheets("Sheet2").Cells.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    Frans

  3. #3
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Simple copy sheet with no formula macro

    After you copy it over, you can then Select all cells, copy them and then PasteSpecial, pasting only the values back onto the cells. This will remove the formulas.
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  4. #4

    Thread Starter
    Member
    Join Date
    Mar 2006
    Posts
    45

    Re: Simple copy sheet with no formula macro

    Thanks guys what you suggest works fine - I asked a tad too soon.

    This is what I have done

    VB Code:
    1. 'Macro to copy over itself to remove formulas
    2. Sub copysheet()
    3.  
    4.     Sheets("Master").Select
    5.     Range("A1:I131").Select
    6.     Selection.Copy
    7.     Sheets("Master").Select
    8.    
    9. Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    10. False, Transpose:=False
    11. Application.CutCopyMode = False
    12. End Sub

    Then called the macro like this

    VB Code:
    1. 'copies Frame sheet to new workbook
    2. Application.Workbooks("getitright").Sheets("Master").Copy Before:=Application.Workbooks("Sheet1").Sheets("Sheet1")
    3. 'calls macro to remove formula
    4. copysheet
    5. 'calls macro to remove extra data
    6. clearextra
    7. 'names the new sheet by the cell value
    8. Application.Workbooks("Sheet1").Sheets("Master").Select
    9. ActiveSheet.Name = Range("A6").Value
    10. 'returns to activate the original workbook and worksheet
    11. Application.Workbooks("getitright").Sheets("Master").Activate

    Seems to be a long way around but it works and I may or may not be able to shorten it later.

    Cheers and thank you for your input. Muchly appreciated.

Posting Permissions

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



Click Here to Expand Forum to Full Width