Anda di halaman 1dari 2

how to return result of multiple cells into a fixed cell in excel - Stack Ove... http://stackoverflow.com/questions/38054226/how-to-return-result-of-mu...

1 of 2

help

how to return result of multiple cells into a fixed cell in excel


i am trying to make a times table chart to test my skills. i used conditional formatting to fill the cell with red color if entered value is wrong
B2<>B$1*$A2 and with blue if entered value is right (B2=B$1*$A2).If i entered wrong value into any cell i want the correct value has to
returned into a fixed cell. suppose if i enter 0 in B2 Cell , the correct value 1 (because 1x1 =1) should be returned to cell (AI9) if i enter wrong
value in any cell i want to see the right value instantly after entering wrong value and hitting enter cell (AI9). so far i am trying from 3 days but i
couldn't figure out how. but i managed to do that for single cell with this formula =IF(B2<>B$1*$A2,B$1*$A2, "") but i have 900 cells . i also
tried =IF(B2:AE31<>B$1:AE$1*$A2:$A31,B$1:AE$1*$A2:$A31, "") in AI9 cell without any success.. so its kind of hard to do that for each cell
manually. any help is greatly appreciated.Thanks in advance. conditional formatting pic
excel

excel-formula
asked 1 hour ago

ap kumar
1

Conditional formatting cannot change the value for another cell. So, this cannot work. Furthermore, you want
your result cell to change as an answer to the most recent cell value changed. So, if someone enters 0 into
B2 and directly afterwards into C2 the value -1 then your result cell should (if I understand correctly) reflect
only the incorrect value for C2. Hence, you'll have to make use of the Worksheet_Change event.
Alternatively, I'd suggest to create a complete error report of all the incorrect values on the sheet. Ralph 1
hour ago
thanks for your reply and suggestion @Ralph. how can i create a complete error report of all incorrect values
on sheet please guide me . thanks in advance. ap kumar 44 mins ago
You'll have to write the appropriate VBA code for that and then the check can be run whenever someone
presses a button to check all cells. This is how I'd do it: (1) copy all cells into a variable (array variable) in
VBA and then (2) loop through the array to check each cell if the value is correct or not. (3) If an error is
found then add a new sheet and start the error report (4) keeping track of all the errors using an error-counter
variable (5) possibly with automatic (clickable) links on the new sheet to automatically redirect to the cell with
the incorrect value. But that's just me. Ralph 40 mins ago

1 Answer

I don't know how much you know about VBA but it sounds like your best answer. Follow the
following steps and it'll do what you're asking for above:
1. Open a new workbook
2. Rename you first sheet "Tables"
3. Press Alt and F11 simultaneously
4. This will open the VBA window - double click on the "Sheet1 (Tables)" icon on the left had
side, as below - The large gray will turn to white, like mine:

5. Click anywhere on the large whit part and insert the below code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 1 Or Target.Column = 1 Then Exit Sub
If (Cells(1, Target.Column) * Cells(Target.Row, 1)) = Target.Value Then
With Target.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorLight2
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
End With
Else
With Target.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 12632310
.TintAndShade = 0
.PatternTintAndShade = 0

6/27/2016 7:52 PM

how to return result of multiple cells into a fixed cell in excel - Stack Ove... http://stackoverflow.com/questions/38054226/how-to-return-result-of-mu...

2 of 2

End With
Application.EnableEvents = False
Range("AI9").Value = Cells(1, Target.Column) * Cells(Target.Row, 1)
Application.EnableEvents = True
End If

End Sub

6. Hit save (near the top-left) and close the VBA window
7. You tables should do what you want it to (and it you have multiple columns, it'll also work)
Note: If you want to change the cell where the correct answer gets put into (as apposed to AI9)
just change that bit with the "AI9" in the bottom part of my code.
I've run this on my own excel and it works perfect
answered 36 mins ago

Jeremy
21

Thanks Thanks Thank you so much @Jeremy you are a pro . works like charm . could you give me code to
analyze which tables i entered wrong while learning . It will be more helpful if you can tell me how to do it .I
can learn faster . Thanks again Jeremy ap kumar 56 secs ago edit

Answer Your Question

6/27/2016 7:52 PM

Anda mungkin juga menyukai