..or shall I call you Mr Excel?
Definitely not!
I have to use this code for more 5 more rows, e.q. in stead of row 8, I have to use this code also for 9, 10, 11 etc.
Try this structure:
<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Worksheet_Change(<SPAN style="color:#00007F">ByVal</SPAN> Target <SPAN style="color:#00007F">As</SPAN> Range)
<SPAN style="color:#00007F">Dim</SPAN> StartRow <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Integer</SPAN>
<SPAN style="color:#00007F">Dim</SPAN> EndRow <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Integer</SPAN>
<SPAN style="color:#00007F">Dim</SPAN> r <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Integer</SPAN>
StartRow = 8
EndRow = 13
Application.EnableEvents = <SPAN style="color:#00007F">False</SPAN>
Columns("IT:IV").EntireColumn.Hidden = <SPAN style="color:#00007F">True</SPAN>
<SPAN style="color:#00007F">For</SPAN> r = StartRow <SPAN style="color:#00007F">To</SPAN> EndRow
<SPAN style="color:#00007F">If</SPAN> Cells(r, 3).Value <> Cells(r, 21).Value <SPAN style="color:#00007F">Then</SPAN>
Cells(r, 23).Value = Cells(r, 256).Value
<SPAN style="color:#00007F">Else</SPAN>
Cells(r, 23).Formula = "=C" & r & "/D" & r & " - 1"
Cells(r, 256).Value = Cells(r, 23).Value
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">If</SPAN> Cells(r, 21).Value <> Cells(r, 22).Value <SPAN style="color:#00007F">Then</SPAN>
Cells(r, 25).Value = Cells(r, 255).Value
<SPAN style="color:#00007F">Else</SPAN>
Cells(r, 25).Formula = "=IF(R" & r & "=0,"""",(U" & r & "/D" & r & "-1))"
Cells(r, 255).Value = Cells(r, 25).Value
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">If</SPAN> Cells(r, 22).Value <> Cells(r, 23).Value <SPAN style="color:#00007F">Then</SPAN>
Cells(r, 26).Value = Cells(r, 254).Value
<SPAN style="color:#00007F">Else</SPAN>
Cells(r, 26).Formula = "=IF(S" & r & "=0,"""",(V" & r & "/D" & r & "-1))"
Cells(r, 254).Value = Cells(r, 26).Value
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">Next</SPAN> r
Application.EnableEvents = <SPAN style="color:#00007F">True</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
And also for two more sheets (in the same excel file)
Do I have to put them all in the same worksheet_Change event? I can see in VBA that every sheet has an own code pane.
Each sheet will need its own Worksheet_Change event code.