• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Just Copy Value From a Worksheet to another Workbook

This Code open a Workbook and Copy a data from a worksheet to paste this to another Sheet. I just need to paste as values while the current version is pasting all.

Code:
Sub ImportDataCN()

Dim wb1 As Workbook
Dim wb2 As Workbook
Dim Sheet As Worksheet
Dim PasteStart As Range

Set wb1 = ActiveWorkbook
Set PasteStart = [CNDATA!A1]

FileToOpen = Application.GetOpenFilename _
(Title:="Please choose a Report to Parse", _
FileFilter:="Report Files *.xl* (*.xl*),")

If FileToOpen = False Then
    MsgBox "No File Specified.", vbExclamation, "ERROR"
    Exit Sub
Else
    Set wb2 = Workbooks.Open(Filename:=FileToOpen)

    ActiveWorkbook.Sheets("Charts").Select
    ActiveWindow.SelectedSheets.Delete
    For Each Sheet In wb2.Sheets
        With Sheet.UsedRange
            .Copy PasteStart
            Set PasteStart = PasteStart.Offset(.Rows.Count)
            End With
    Next Sheet

End If

wb2.Close

  'Sheets("RRimport").Select
  'Rows(1).Delete
  Sheets("SR Allocation").Select

End Sub
 
Hi Kuldeep

Change

Code:
.copy PasteStart

to something like

Code:
.copy
PasteStart.pastespecial xlpastevalues

That should ensure just the values are transferred.

Take care

Smallman
 
Make sure Smallman's code is on two lines, and not 1 line as before. Since you're doing a PasteSpecial, we don't want to use the Copy method's destination argument.
 
A simple cut and paste over the top of this line

Code:
.copy PasteStart

with the two lines I provided would have made your code work flawlessly.

Take care

Smallman
 
Back
Top