Formula's disappear

VBA

New Member
Joined
Jan 19, 2009
Messages
39
I'm all confused :confused:

I run a macro, and suddenly the formula's in my sheet disappear - leaving only the values they produce :(

Thus: when I run the macro, {=sum(A1:A100)/counta(A1:A100)} becomes {100}, which is indeed the value of that formula but why can't I see the formula behind it anymore when I click on the cell? :confused:

used macro

Greetings,
;)
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Ok, thank you for the swift answer :)

I'll try skipping the cells with formula's then ;) Should be possible.

Greetings.
 
Upvote 0
For some reason it does not work anymore :(
It gives the error: "next without for", so I guess that 2nd If destroys it all, but I said in an earlier post that it worked nicely! I do not know why I did then and not now.

Anybody an idea how to change this into something which works? I need the code in red as otherwise I loose the formula's in the sheet when I delete the blank spaces.

For more info, see first macro and addition. I guess I should place it somewhere else? :rolleyes:

Sub NoBL()
Dim c As Range
For Each c In ActiveSheet.UsedRange
If Left(c.Value, 1) = Chr(160) Then c.Value = Right(c.Value, Len(c.Value) - 1)
If Not c.HasFormula Then
c.Value = c.Value
Next c
End Sub
 
Upvote 0
Thank you :)

It did not occur to me that End If was needed, as the macro worked perfectly without it as long as I had only one if-statement in it. I am still not quite sure how this works, but when I find the time I will look into it.

Thanks again for your swift reply!
 
Upvote 0
You don't need End If if the statement is all on one line like this:

Code:
If Not c.HasFormula Then c.Value = c.Value
 
Upvote 0

Forum statistics

Threads
1,213,565
Messages
6,114,337
Members
448,568
Latest member
Honeymonster123

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