GaryChrist Posted April 6, 2016 Share Posted April 6, 2016 Hi all, I want to copy Values from workbook A to workbook B. This is what I use: $oRange3 = $oWorkbookUpdate.Worksheets(1).Range("Q3:AA3") $oLastRow = $oWorkbookS.Worksheets(1).UsedRange.Rows.Count _Excel_RangeCopyPaste($oWorkbookS.Worksheets(1),$oRange3, "A" & $oLastRow+1, Default, $xlPasteValuesAndNumberFormats) But somehow the $xlPasteValuesAndNumberFormats is not working, I still get the formula pasted at workbook B, while what I want is the values only. Anyone can help on this? Link to comment Share on other sites More sharing options...
water Posted April 6, 2016 Share Posted April 6, 2016 What is the value of @error and @extended after _Excel_RangeCopyPaste? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
GaryChrist Posted April 6, 2016 Author Share Posted April 6, 2016 I use this line below the _Excel_RangeCopyPaste to capture the error: If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example 4", "Error copying rows." & @CRLF & "@error = " & @error & ", @extended = " & @extended) I don't get any error messages, my function is just keep going on, anything wrong with line above? Link to comment Share on other sites More sharing options...
water Posted April 6, 2016 Share Posted April 6, 2016 Your code looks good so far. I'm on a business trip right now and will return on Friday. On Saturday I will leave for a two week vacation. Hope I find some spare time to check before I'm off for vacation. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
GaryChrist Posted April 6, 2016 Author Share Posted April 6, 2016 Solved already, I use RangeRead & RangeWrite: $oCopy3 = _Excel_RangeRead ($oWorkbookUpdate,1,"Q3;S3:AA3") If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 1", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended) $oLastRow = $oWorkbookS.Worksheets(1).UsedRange.Rows.Count _Excel_RangeWrite ($oWorkbookS,1,$oCopy3,"A" & $oLastRow+1,True) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example 1", "Error writing to worksheet." & @CRLF & "@error = " & @error & ", @extended = " & @extended) But still, I wonder why RangeCopyPaste won't give me the values.. Link to comment Share on other sites More sharing options...
alien4u Posted April 6, 2016 Share Posted April 6, 2016 Maybe because RangeCopyPaste only copy Formulas and not Values on Cells and in the other hand RangeRead do it in a different way, so maybe you should look inside the RangeCopyPaste function and you can figure it out. Kind Regards Alien. Link to comment Share on other sites More sharing options...
water Posted April 6, 2016 Share Posted April 6, 2016 As described in the help file: "If $vSourceRange and $vTargetRange are specified parameters $iPaste, $iOperation, $bSkipBlanks and $bTranspose are ignored" My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now