Solved

tricky copy and special paste data

Posted on 2014-01-13
7
243 Views
Last Modified: 2014-01-13
Hi Expert's excel 2007

I need a macro that will copy data from worksheet pivot...based on the data in column a I.e copy all the data above the txt Grand Total and paste into new workbook and save workbook to file path \\gpobal.yftuu\hfghj\ da
te & .xlsx file...

starting range is always A6:hx where is depend on column a and one less grand total txt..
0
Comment
Question by:route217
  • 4
  • 3
7 Comments
 
LVL 31

Expert Comment

by:Rob Henson
Comment Utility
Is there anything else on the Pivot sheet?

If not you can just do a Worksheet Copy and then break the links or copy and paste all with values.

If that is what you want, let us know and I will sort the macro for you.

Thanks
Rob
0
 

Author Comment

by:route217
Comment Utility
Nothing else in pivot....

I do not trust the end users...I would kindly like the macro please
0
 
LVL 31

Expert Comment

by:Rob Henson
Comment Utility
OK, couple of questions then:

1) Name of sheet containing Pivot
2) Path & Filename required for Saved file
3) Do you want to get rid of Rows 1 to 5 above copied pivot and row containing Grand Total

Thanks
Rob H
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:route217
Comment Utility
1. Pivot - confirmed
2. \\global.test\heujejek\   ps I can amend...
3. Yes and yes in the new pasted workbook and paste into sheet 1 also re name sheet 1 as confirmed numbers and delete sheets 2 and 3.
0
 
LVL 31

Accepted Solution

by:
Rob Henson earned 500 total points
Comment Utility
Here's something to get you started, let me know if need any changes.

Sub CopySheet()
    
    Sheets("Pivot").Select
    Sheets("Pivot").Copy
    Cells.Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    Rows("1:5").Select
    Selection.Delete Shift:=xlUp
    Range("A1").Select
    Cells.Find(What:="Grand Total", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate
    Selection.EntireRow.Delete
    Sheets("Pivot").Select
    Sheets("Pivot").Name = "Confirmed"
    FilePath = "\\global.test\heujejek\"
    NewFileName = "Pivot Copy 140113.xlsx"
    ActiveWorkbook.SaveAs Filename:=FilePath & NewFileName, FileFormat:= _
        xlOpenXMLWorkbook, CreateBackup:=False
    ActiveWindow.Close

End Sub

Open in new window

I guess you will need some dynamic way of changing the filename. What naming convention will you need?

Thanks
Rob H
0
 

Author Comment

by:route217
Comment Utility
Thanks Rob H ...let me test kindly.
0
 
LVL 31

Expert Comment

by:Rob Henson
Comment Utility
Take your time, I will be online until 17:00 GMT.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now