VBA show result only in cell

iainmartin100

New Member
Joined
Mar 9, 2011
Messages
43
Hi,

I have searched and seached the forum but cant find the answer to this most basic question.

I have a line of code which puts a formula into cell A1.
All I want to do is have the code do the formula and the result only show in cell A1.

Here's an example of the code:
Range("A1").Formula = "='C:\[Book2.xls]Sheet1'!$B$4"

If the result was 5 then I just want to see 5 in the cell rather than the forumla behind the result also (vaule only).
The reason is to reduce the size of a large excel document with hudreds of formula all doing simular things.

Many thanks
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
One way

Code:
With Range("A1")
    .Formula = "='C:\[Book2.xls]Sheet1'!$B$4"
    .Value = .Value
End With
 
Upvote 0
Thanks for the reply, do you know of any way I can do this in one line of code?

The reason being is that I have maybe 3000 forumla's to do this on so wanted to do a simple 1 line per cell script?

Thank you
 
Upvote 0
Try this - Book2 must be open

Code:
Range("A1").Value = Workbooks("Book2.xls").Sheets("Sheet1").Range("B4").Value
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,576
Members
448,972
Latest member
Shantanu2024

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