Compile error: Expected: Expression

Strogg

New Member
Joined
Dec 5, 2018
Messages
5
Hey everybody.
I've tried to make some simple calculations, but you see what happened. What is the reason of the compile error?
f8rgWjc.jpg
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
x is undeclared; otherwise works fine for me.

Code:
Public Sub N1()
  Dim x As Double, z As Double, y As Double
  Dim a As Single, b As Single, c As Single
  a = 7.57: b = 6.28: x = 3.14
  y = (a + b) / (Sqr(Abs(Sin(x))))
  z = Sin(y) + Exp(-x)
  Debug.Print "y="; Format(y, "###0.000")
  Debug.Print "z="; Format(z, "###0.000")
End Sub

Output:
Code:
y=347.048
z=1.038

As matters of practice, I wouldn't give a procedure a name that looks like a cell reference, and absent a good reason, would declare all floating-point numbers as Doubles.
 
Upvote 0
I've tried to use your code, but error didn't disappear.
I actually think the problem is not about the code. VBA on my home PC can't compile any macro I try to compile. It seems there is something wrong with Excel and VBA on my computer.
Anyway, thank you so much.
 
Upvote 0
Installing VBA is optional when you install Excel.
 
Upvote 0

Forum statistics

Threads
1,223,981
Messages
6,175,767
Members
452,668
Latest member
mrider123

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