fundamental differences in codes

RSXchin

Well-known Member
Joined
Oct 23, 2010
Messages
758
is there any real difference (if I'm only worrying about values) between
Code:
    With Range("A1:A10")
        .Copy
        .PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    End With

and

Code:
    With Range("A1:A10")
        .Formula = .Value
    End With

?
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
I think you would want to use

.Value = .Value (not .Formula = .Value)


1 advantage to doing Value = Value instead of copy / pastespecial

When you have formulas returning ""
And you copy / PasteSpecial / Values
Those "" are NOT Truely Blank, they are NULL Text Strings.
So things like IsBlank will NOT see them as blank.

.Value = .Value resolves that issue.
 
Upvote 0
awesome!!! that'll make my codes easier to understand for my replacements anyway. Are there any limitations with that?

i.e. if I wanted to do it with the entire sheet, would it give me a memory overflow or something like it?
 
Upvote 0
I think you would want to use

.Value = .Value (not .Formula = .Value)


1 advantage to doing Value = Value instead of copy / pastespecial

When you have formulas returning ""
And you copy / PasteSpecial / Values
Those "" are NOT Truely Blank, they are NULL Text Strings.
So things like CountBlank will NOT see them as blank.

.Value = .Value resolves that issue.

.Value = .Value

== awesomer!

Thank you
 
Upvote 0
I don't know, I've never tested it's limits.
You tell us..

It may have problems with formula errors...maybe..
 
Upvote 0
I misspoke when I said ".value = .value"

Because that leaves the formulas. That's not what I wanted at all... I'll stick with ".Formula = .Value"
 
Upvote 0
I misspoke when I said ".value = .value"

Because that leaves the formulas. That's not what I wanted at all... I'll stick with ".Formula = .Value"

No it doesn't.

The only way I can make .value = .value result with a formula in a cell is if I enter a formula as a text string beginning with an apostrophe like

'=SUM(B1:B10)

With that in the cell, it is NOT a formula, it's viewed as a text string
Then the .value = .value makes it a formula
But .Formula = .Value does as well.

If I do the .value = .value again, then it removes the formula, and leaves the result of the formula.
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,844
Members
452,948
Latest member
UsmanAli786

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