Solved

Amend Transfer code

Posted on 2014-07-30
6
97 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
[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
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

752 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