Excel Vba .value same as .Copy .PasteSpecial xlPasteValues

Biz

Well-known Member
Joined
May 18, 2009
Messages
1,773
Office Version
  1. 2021
Platform
  1. Windows
Hi,

I always thought .value=.value was same as .copy .PasteSpecial xlPasteValues but I found it's not same when a formula is used which returns "".

Code:
 'Assessment# Dup
    With Range("AA2:AA" & LastRow)
    '"=IF(COUNTIF(R2C20:R30591C20,RC[-1])>1,1,"""")"
        .Formula = "=IF(COUNTIF($Z$2:$Z$" & LastRow & ",Z2)>1,1,"""")"
'        .Value = .Value
        
        .Copy
        .PasteSpecial xlPasteValues
'        .PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
'        :=False, Transpose:=False
    Application.CutCopyMode = False
    End With

Is there a better way to solve this problem?

Your help would be greatly appreciated.

Kind Regards

Biz
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
I believe the only only difference in this case is that you will not end up with the value of an empty string, you will end up with a blank cell.
How does this affect what you are trying to do?
 
Upvote 0
Hi Scott,

This affects my sort ordeer as 1 indicates, items to deleted and "" items to ignore. I use results to sort data and then delete items based on code below.

Code:
'Sort by Delete
    Set aSheet = Sheets("Report")
    
    'Add Sort Keys
    With aSheet.Sort
        .SortFields.Clear
        .SortFields.Add Key:=Range("AD2:AD" & LastRow), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
    End With
    
    'Sort to Delete
    With aSheet.Sort
        .SetRange Range("A1:AD" & LastRow)
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    
    aSheet.Range("AD2", Range("AD1").end(xlDown)).SpecialCells(xlCellTypeConstants, 1).EntireRow.Delete

Kind Regards

Biz
 
Upvote 0

Forum statistics

Threads
1,221,059
Messages
6,157,679
Members
451,432
Latest member
Rizzy73

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top