logic test output to seperate cell

ronniewb

New Member
Joined
Jan 29, 2012
Messages
4
I am developing a sheet to do some debt analysis. I have an input cell for loan value (B1), interest rate (F1), term (months)(H1), and payment(J1). I also have a set of cells that will calculate each of these values individually, given the other 3 values (J4-7 respectively). What I am trying to accomplish is to be able to manually input the values in the input cells, or to have a logic test determine if one input cell is empty, and use the other 3 to calculate it and insert the calculated value. I can not put a formula directly in the input cell because a manual entry will overwrite the formula for future use (and I plan to protect the cells with formulas).

Ideas?
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
A starting point for you. This set up:
Excel Workbook
ABCDEFGHIJ
1Input row1233345
2
3
4Answers111222333444
Sheet


with this code in the code module of the same sheet:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If [=COUNT(B1,F1,H1,J1)] = 3 Then
  For Each cll In Range("B1,F1,H1,J1")
    If IsEmpty(cll) Then cll.Value = cll.Offset(3).Value
  Next cll
End If
End Sub
 
Upvote 0
Thank your for your reply. I have never worked with macros or VB, and may have bitten off more than I can chew. My sheet looks very similar to yours (in layout) except that my substitution values are in the row directly below the original inputs, and they are formulas, not text. Also I am trying to call the macro unknownvalues, and I'm sure that is messing something up.
 
Upvote 0
Thank your for your reply. I have never worked with macros or VB, and may have bitten off more than I can chew. My sheet looks very similar to yours (in layout) except that my substitution values are in the row directly below the original inputs,
A very small change to the code:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If [=COUNT(B1,F1,H1,J1)] = 3 Then
  For Each cll In Range("B1,F1,H1,J1")
    If IsEmpty(cll) Then cll.Value = cll.Offset([B][COLOR=Red]1[/COLOR][/B]).Value
  Next cll
End If
End Sub
You should place this as follows: on the sheet's tab, right-click, choose View Code..., paste the above where there's a flashing cursor. Close that newly appeared window, if it works then saving the workbook will save the macro.
and they are formulas, not text.
It matters not
Also I am trying to call the macro unknownvalues, and I'm sure that is messing something up.
What is your code?
 
Upvote 0
OK, that's getting really close. Problem now is it won't let you leave a space blank while you input the other three, and its hard to tell which variable you are trying to manipulate. Is there a way to add a "calculate" button that will run the macro through one cycle, then stop?
WOW though, thanks.
 
Upvote 0
So delete more than one together first, then input. It will only trigger when there's a single blank left.
Otherwise:
A button assigned to the following macro:
Code:
Sub CalculateWhatsLeft()
If [=COUNT(B1,F1,H1,J1)] = 3 Then
  For Each cll In Range("B1,F1,H1,J1")
    If IsEmpty(cll) Then cll.Value = cll.Offset(1).Value
  Next cll
End If
End Sub
 
Upvote 0
That worked, but with protection enabled you had to control to multi select. But I was able to add a form control button that did a wonderful job. Thank you so much for your help.
 
Upvote 0

Forum statistics

Threads
1,214,984
Messages
6,122,601
Members
449,089
Latest member
Motoracer88

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