View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Nhien Nhien is offline
external usenet poster
 
Posts: 5
Default VBA code to copy and paste by values from one Excel workbook to another

On Aug 14, 5:47 pm, "Dan R." wrote:
Nhien,

Put this at the top of your code:

Application.DisplayAlerts = False

then put this at the bottom:

Application.DisplayAlerts = True

--
Dan


Thanks, I was able to get the DisplayAlerts to work. The only problem
I have now is after pasting the data, I want to remove the highlight
from the sheet. Here's my code. I get an error at
ws.Range("A1").Select. What am doing wrong?


Dim XL As Excel.Application
Dim wb As Workbook
Dim wb2 As Workbook
Dim ws As Worksheet


Set wb2 = Workbooks.Open(strMainFile)
Set ws = wb2.Sheets("POC_datasheet")
Set wb = Workbooks.Open(strWorkFile)
Set XL = wb2.Parent
XL.DisplayAlerts = False



wb.Sheets("POC_data").Range("A1:F65").Copy
ws.Range("A1:F65").PasteSpecial xlPasteValues
ws.Range("A1").Select

wb.Close SaveChanges:=True
wb2.Close SaveChanges:=True

-Nhien