Solved

Amend Transfer code

Posted on 2014-07-30
6
96 Views
Last Modified: 2014-07-31
Hi,

I need an amendment to the following piece of code

The copy is a regular paste, i need a paste special

Many thanks

Sub macro()
Dim arrData As Variant
Dim arrTransfer As Variant
LastTransferRow = Sheets("Change Summary").Range("A" & Rows.Count).End(xlUp).Row
arrData = Join(WorksheetFunction.Index(Sheets("Add Delete Team Members").Range("N15:W17").Value, 1, 0), ";")
arrTransfer = Join(WorksheetFunction.Index(Sheets("Change Summary").Range("N" & LastTransferRow & ":A" & LastTransferRow).Value, 1, 0), ";")
If arrData = arrTransfer Then
    Res = MsgBox("This is the same data, are you sure you want to send", vbYesNo)
    If Res = vbYes Then
        Sheets("Add Delete Team Members").Range("N15:W17").Copy Sheets("Change Summary").Range("A" & LastTransferRow + 1)
    Else
        Exit Sub
    End If
Else
    Sheets("Add Delete Team Members").Range("N15:W17").Copy Sheets("Change Summary").Range("A" & LastTransferRow + 1)
End If
End Sub

Open in new window

0
Comment
Question by:Seamus2626
  • 3
  • 3
6 Comments
 
LVL 13

Expert Comment

by:duncanb7
ID: 40229377
You can try this,

Sheets("Change Summary").Range("A" & LastTransferRow + 1).PasteSpecial   xlPasteValues  

OR

Sheets("Change Summary").Range("A" & LastTransferRow + 1).PasteSpecial    xlPasteFormats
0
 

Author Comment

by:Seamus2626
ID: 40229402
Hi Duncan,

I dropped that in and got the error message

"Invalid use of property" on line xlPasteValues

Sub New_Staff()
Dim arrData As Variant
Dim arrTransfer As Variant
LastTransferRow = Sheets("Change Summary").Range("A" & Rows.Count).End(xlUp).Row
arrData = Join(WorksheetFunction.Index(Sheets("Add Delete Team Members").Range("N15:W17").Value, 1, 0), ";")
arrTransfer = Join(WorksheetFunction.Index(Sheets("Change Summary").Range("N" & LastTransferRow & ":A" & LastTransferRow).Value, 1, 0), ";")
If arrData = arrTransfer Then
    Res = MsgBox("This is the same data, are you sure you want to send", vbYesNo)
    If Res = vbYes Then
        Sheets("Add Delete Team Members").Range("N15:W17").Copy Sheets("Change Summary").Range("A" & LastTransferRow + 1).PasteSpecial
        xlPasteValues


    Else
        Exit Sub
    End If
Else
    Sheets("Add Delete Team Members").Range("N15:W17").Copy Sheets("Change Summary").Range("A" & LastTransferRow + 1).PasteSpecial
    xlPasteValues
End If
End Sub

Open in new window

0
 
LVL 13

Expert Comment

by:duncanb7
ID: 40229421
Could you  write your question in detail , what you want which sheet which range or cell to get pasteSpecial and what format for the paste you want ?

duncan
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:Seamus2626
ID: 40229473
Okay,

So my code picks up range N15:W17 from tab "Add Delete Team Members" and pastes over to tab "Change Summary", it pastes to the next available row after the headings (A1:L1)

When it pastes, its pastes with formats, i do not want the formats, i only want the values

Thanks
0
 
LVL 13

Accepted Solution

by:
duncanb7 earned 500 total points
ID: 40229485
You need to the put the range and sheet  you want with this PasteSpeical with values only

.PasteSpecial   xlPasteValues
0
 

Author Comment

by:Seamus2626
ID: 40229516
Thanks Duncan but It does not work on this code

Put that line into my code where you would put it and i will run

Thanks
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

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,…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

821 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