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
 

Some videos you may like

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
One way

Code:
With Range("A1")
    .Formula = "='C:\[Book2.xls]Sheet1'!$B$4"
    .Value = .Value
End With
 

iainmartin100

New Member
Joined
Mar 9, 2011
Messages
43
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
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try this - Book2 must be open

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

Watch MrExcel Video

Forum statistics

Threads
1,122,193
Messages
5,594,774
Members
413,934
Latest member
austinb

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
Top