When I calculate in the VB editor I get round off errors.
I have the following:
Excel cells:
E3 is =CalcResult(C3;F3;B3) (Sending the values to the VB editor)
C3 is changeable, 1 to 6
CF is changeable, 1 to 6
B3 contains the value I want to calculate
In VB Editor:
Function CalcResult(Arg1 As...
Now it's working! :o)
I had a bad link that caused all the problems. I fixed it from Edit > Links. Thank you very much for that!
Now I'm very happy.
Thank you all once again. What would I've done without you all. I've learned a lot during this problem. Hopefully I can fix minor problem like...
What I want to do and why is described here:
http://www.techonthenet.com/excel/macros/if_custom.htm
The difference is that I want to:
A) Send more than one argument (CalcValue(C14;F14;B14) instead of (CalcValue(A1)).
B) Calculate a value depending on a argument (Arg3) and return the result...
The big problem seems to be that it always ask for a makro in another Excel file. That file is the one I started out with. This file I'm working in now is created with the command NEW and then I copy & pasted alla the cells from the original file. All but one cell - the one with the VB call...
First I will give you the whole picture:
I have two cells (C14 and F14) which both contains values from 1 to 6 (Arg1 and Arg2). Theese are changeable so if I set the first cell to 3 and the second to 6 I want a certains calculation to happen. This means that I have more than seven IF statements...
I've tried that - it didn't work.
(I also saw some errors in the code I sent here. It should be CalcValue4 in all three places. I've tried that too and it didn't work out either.)
Ok, now it looks like this:
In my Excel sheet in one cell I have this formula:
=CalcValue4(C14;F14;B14)
and in the VB Editor I now have:
Sub CalcValue4(Arg1 As Long, Arg2 As Long, Arg3 As Long)
If Arg1 = 1 And Arg2 = 2 Then
CalcValue = Arg3 * 2.5
ElseIf Arg1 = 2 And Arg2 = 2 Then
CalcValue =...
Thank you both for your answers. It sounds logic but it still doesn't work for me. I think it's some other thing that is wrong.
When I choose Tools/Macro (Alt + F8) I can't see any macro there, but when I click Alt + F11 the code shows in the module.
If I write the macro name in the macro...
Hi All!
1) In the Visual Basic Editor I want to know what is the correct way to refer to a cell so I can use its value in a calculation?
Here's my code:
Function CalcValue(Arg1 As String, Arg2 As String) As Long
If Arg1 = "1" And Arg2 = "2" Then
CalcValue =...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.