Converting a range of formulae to values

NewOrderFac33

Well-known Member
Joined
Sep 26, 2011
Messages
1,283
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
Good afternoon,
I have the following procedure which adds a formula to a range, then attempts to convert the resulkts of those formulae into values.
Code:
Sub AlignAndFormatTotalLeadTimes()
    Set TotalLeadTime = Sheets("Database").Range("Col_DB_TotalLeadTime")
    'Right align apply number format and remove "NULL" or zero values from Total LeadTime column
    With Range("Col_DB_TotalLeadTime")
        .NumberFormat = "[h]""h"" mm""m"" ss""s"""
        .HorizontalAlignment = xlRight
        .FormulaR1C1 = "=IF(OR(RC[-3]=0,RC[-1]=0),""-"",RC[-1]-RC[-3])"
        .Formula = .value
    End With
End Sub

However, I would expect the" .value" to be capitalized i.e. ".Value", but it just seems to be ignored and doesn't snap into place like I'd expect it to.

Can anyone suggest what I'm doing wrong, please?

Thanks in advance

Pete
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Try replacing:
VBA Code:
.Formula = .value
with
VBA Code:
.Value = .Value
 
Upvote 0
However, I would expect the" .value" to be capitalized i.e. ".Value"
That would suggest you have (at some time) created a variable or procedure called value.
If you type Dim Value at the top of the code & hit enter, the capitalisation should return. You can then delete the Dim statement.
 
Upvote 0
That would suggest you have (at some time) created a variable or procedure called value.
If you type Dim Value at the top of the code & hit enter, the capitalisation should return. You can then delete the Dim statement.
That's it! For some bizarre reason, I have a Public function that declares "value" as a variant type (probably copied from here or StackOverflow and I never renamed the variables.
I've renamed it, and all the .value" s have disappeared.
I'd NEVER have figured that out - thanks very much!
Pete
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,721
Messages
6,174,097
Members
452,542
Latest member
Bricklin

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