Solved

i would like to know how do i am using paste specail in excel VBA

Posted on 2014-01-19
5
377 Views
Last Modified: 2014-02-17
i would like to copy from one spreadsheet to another and i would like to know what is the command for copying value and for coping formula

for example i have the following line, how its should be written for each case (for value and for formula)?

wksDest.Range(Cells(rng.Row, 244), Cells(rng.Row, 318)).Copy
               wksSource.Activate
               Cells(lastRow + 1, 107).PasteSpecial xlPasteAll, Paste:=xlPasteCommens

and what is the meaning of .PasteSpecial xlPasteAll

Thanks
Gvilbis
0
Comment
Question by:gvilbis
  • 2
5 Comments
 
LVL 26

Assisted Solution

by:MacroShadow
MacroShadow earned 167 total points
ID: 39792515
Sub Demo()
    ' to copy
    wksDest.Range(Cells(Rng.Row, 244), Cells(Rng.Row, 318)).Copy
    ' to paste values
    wksSource.Range(Cells(lastRow + 1, 107)).PasteSpecial xlPasteAll, Paste:=xlPasteValues
    ' to paste formulas
    wksSource.Range(Cells(lastRow + 1, 107)).PasteSpecial xlPasteAll, Paste:=xlPasteFormulas
End Sub

Open in new window


Paste is the argument which determines what part of the range will be copied. The options are:
xlPasteAll - Everything will be pasted.
xlPasteAllExceptBorders - Everything except borders will be pasted.
xlPasteAllMergingConditionalFormats - Everything will be pasted and conditional formats will be merged.
xlPasteAllUsingSourceTheme - Everything will be pasted using the source theme.
xlPasteColumnWidths - Copied column width is pasted.
xlPasteComments - Comments are pasted.
xlPasteFormats - Copied source format is pasted.
xlPasteFormulas - Formulas are pasted.
xlPasteFormulasAndNumberFormats - Formulas and Number formats are pasted.
xlPasteValidation - Validations are pasted.
xlPasteValues - Values are pasted.
xlPasteValuesAndNumberFormats - Values and Number formats are pasted.
0
 

Author Comment

by:gvilbis
ID: 39792626
what is the default of pasting if not mention Paste:=xlPasteFormulasvalues or Paste:=xlPasteValues?

Thanks
Gvilbis
0
 
LVL 42

Accepted Solution

by:
Rob Jurd, EE MVE earned 333 total points
ID: 39792806
You can also find out about what's required or default by using the inspector (F2) in the VBA editor.  As you can see below, xlPasteAll is the default as defined by the function

vba editor / inspector
0
 
LVL 42

Assisted Solution

by:Rob Jurd, EE MVE
Rob Jurd, EE MVE earned 333 total points
ID: 39792812
As MacroShadow has indicated xlPasteAll will copy all formatting, formulas and values from the range you have selected to copy.

It may give you a better idea about what's happening by just performing a paste special via the ribbon

ie

paste special options
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

708 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

17 Experts available now in Live!

Get 1:1 Help Now