Solved

Copy worksheet without references or formulas

Posted on 2015-01-19
7
87 Views
Last Modified: 2015-01-19
Hello Experts,

The following code copies a worksheet which works. However, I need to copy the worksheet with the formatting, graphs, etc but without any formulas or references to other worksheets.

Sub AddSheet()

    Dim lngSheets As Long
    Dim intCount As Integer
   
    ActiveSheet.Copy After:=Sheets(Sheets.Count)
   
    For lngSheets = 1 To Sheets.Count
        If Left$(Sheets(lngSheets).Name, Len(Range("N1"))) = Range("N1") Then
            intCount = intCount + 1
        End If
    Next
    If intCount > 0 Then
        ActiveSheet.Name = Range("N1") & intCount
    Else
        ActiveSheet.Name = Range("N1")
    End If
       
End Sub
0
Comment
Question by:bikeski
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 6

Assisted Solution

by:Flora
Flora earned 100 total points
ID: 40558828
add this line ActiveSheet.UsedRange.Value = ActiveSheet.UsedRange.Value
0
 
LVL 47

Accepted Solution

by:
Martin Liss earned 400 total points
ID: 40558920
Sub AddSheet()

    Dim lngSheets As Long
    Dim intCount As Integer
    
    ActiveSheet.Copy After:=Sheets(Sheets.Count)
    
    With ActiveSheet.UsedRange
        .Value = .Value
    End With
    
    For lngSheets = 1 To Sheets.Count
        If Left$(Sheets(lngSheets).Name, Len(Range("N1"))) = Range("N1") Then
            intCount = intCount + 1
        End If
    Next
    If intCount > 0 Then
        ActiveSheet.Name = Range("N1") & intCount
    Else
        ActiveSheet.Name = Range("N1")
    End If
       
End Sub

Open in new window

0
 
LVL 6

Expert Comment

by:Flora
ID: 40558922
Hi Martin.

 that this exactly as I suggested. you did the shortcut using "With"

:-)

anyways, I am your pupil
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Closing Comment

by:bikeski
ID: 40558934
Thanks, that worked. I gave Martin more points as he provided the full code;)
0
 
LVL 6

Expert Comment

by:Flora
ID: 40558935
not fair :)
0
 
LVL 47

Expert Comment

by:Martin Liss
ID: 40558986
Flora, my code did use With, but more importantly it showed the author where to add the new code. In any case if you really don't think the current split is fair I'm happy to split the points with you 50/50. Just Request attention.
0
 
LVL 6

Expert Comment

by:Flora
ID: 40558991
Martin,
no worries, of course I was just messing/joking with you :-)  
points are not important, what is important is that author got his answer and everyone is happy, including me :-)

thank you for being so generous and so nice.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question