using 2007 - I have a user form that gathers data concerning the DCMA 14 Point Metric. After the calculation, the user has the option to export the data to Excel. During the export, I create separate tabs/sheets for each of the 14 metrics and then copy the appropriate data into each sheet.
Problem - sometimes the data is copied and sometimes not. If I have "On Error Resume Next" turned off, the error is in the "PasteSpecial" line
xlApp.ActiveSheet.PasteSpecial Format:="Unicode Text"
as stated, this is not consistent - sometimes it works and sometimes I get the error.
If I have "On Error Resume Next" turned on, I don't get the error, but the data is not pasted.
here is some of the code
'===================== copy data to Excel =========================
'===copy Logic
xlApp.Sheets("Logic").Select
xlApp.Range("A3") = "data goes here"
'set filter
FilterApply Name:="MissingLogic"
'select data and count
SelectTaskColumn Column:="ID"
'On Error Resume Next
linkscount = Application.ActiveSelection.Tasks.count
'select data to be copied
SelectTaskField Row:=0, Column:="ID", Width:=15, Height:=linkscount, Extend:=True
Application.EditCopy
If linkscount > 0 Then
'select cell to paste data
xlApp.Range("A3").Select
'pastespecial Unicode Text
xlApp.ActiveSheet.PasteSpecial Format:="Unicode Text"
Else
'if no data found, insert message
xlApp.Range("A3") = "No data found"
End If
linkscount = 0
'===copy Leads
xlApp.Sheets("Leads").Select
xlApp.Range("A3") = "data goes here"
FilterApply Name:="Leads"
SelectTaskColumn Column:="ID"
'On Error Resume Next
linkscount = Application.ActiveSelection.Tasks.count
SelectTaskField Row:=0, Column:="ID", Width:=15, Height:=linkscount, Extend:=True
Application.EditCopy
If linkscount > 0 Then
xlApp.Range("A3").Select
xlApp.ActiveSheet.PasteSpecial Format:="Unicode Text"
Else
xlApp.Range("A3") = "No data found"
End If
linkscount = 0
================
I have written a fair amount of VBA, but I have never seen this. Anybody have a clue?
GEM