VB Module - Copy values only from sheet 1 to sheet 2

I'm trying to create a module that copies the data I have in sheet 1 of my spreadsheet (mainly hyperlinks) and pastes the values only into sheet 2. Below is what I've tried so far but I keep getting error messages. When I try to debug it indicates that the errors have something to do with line  "Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False"

Sub Extract()
'
    ActiveSheet.Outline.ShowLevels RowLevels:=8
    Cells.Select
    Selection.Copy
    Sheets("Sheet2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
End Sub

If anyone has any suggestions or an alternative script it would be greatly appreciated.
Emma
x5225642Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Roy CoxGroup Finance ManagerCommented:
The code works fine for me. This would be more efficient

ActiveSheet.Outline.ShowLevels RowLevels:=8
    ActiveSheet.Cells.Copy
    Sheet2.Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

Open in new window

To get to the bottom of your problem attach the workbook
Saurabh Singh TeotiaCommented:
Assuming you want to paste on cell a1 then you can simply do this..

Sub Extract()
'
    ActiveSheet.Outline.ShowLevels RowLevels:=8
    Cells.Copy
    Sheets("Sheet2").Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End Sub

Open in new window


Saurabh...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.