GaryChrist

[Help] _Excel_RangeCopyPaste - paste special is not working

7 posts in this topic

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? 

Share this post


Link to post
Share on other sites



What is the value of @error and @extended after _Excel_RangeCopyPaste?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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..

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now