Hi all,
I am a bit of a novice in vba and am trying to fix an issue that I can't quite wrap my head around despite extensive research. I would love for you guys to give me your thoughtful advice.
I am basically working with a model that enables the user to change assumptions and get an updated forecast based on their new inputs. I have created a form as a front-end that has different labels and text-boxes referencing cells in the back-end excel worksheet. For example i have:
NonFarm1value.Caption = Sheets("Sheet1").Range("C5").Value
NonFarmCAGR1 = Sheets("Sheet1").Range("D6")
So when the user changes NonFarmCAGR1, he should see nonfarm1value grow or decrease accordingly. Now since it is a CAGR, I have formatted the nonfarmcarg1 textbox as a percentage instead of having it displaying a number with 16 decimals. using the following code:
Me.NonFarmCAGR1.Text = Format(Sheets("Sheet1").Range("D6"), "0.00%")
So the problem I am running into is that when I have the event that says: when nonfarmcagr changes
Sheets("Sheet1").Range("D6")=NonFarmCAGR1.value
, if the user just clicked and actually didn't change anything the value gets rounded and the forecast therefore slighty changes. For exemple if the base value is 0.0161616 that is displayed 1.62%, if the user click, the value in cell D6 will become
0.0162. I have try using if statements and rounds but I couldn't figure it out.
Additionally D6 actually reference another cell N6, and when the user click and doesn't actually change the value, it would be even better if the formula in D6 stayed "=N6" instead of becoming the value 0.0161616.
Any thoughts on what I could implement?
Thanks in advance,
Thi
FYI, I tried something like this, which wasn't quite working and seems over complicated to me:
if Sheets("Sheet1").Range("D6").Value=round(Sheets("Sheet1").Range("N6").Value,5)Then
Sheets("Sheet1").Range("D6").Formula = "=N6"
Else
Sheets("Sheet1").Range("D6").Value=NonFarmCAGR1.Value
End if
Bookmarks