I am trying to develop a code that will first check if a sheet is visible and if so, it will "copy" the value from a specific cell to a specific cell on another sheet.
Here is the code that is currently working:
Now this code has to be repeated 15 times (and possibly more in the future). So I would like to give my fingers a break if possible and simplify it to a For i = 1 to 15 type situation... but I can't seem to figure it out. Please notice that the Index sheet Range increases by 1 row for each bearing sheet (i+11). But the Bearing sheet range is always the same ("D2")
The other issue is that if I do type it all out (pain, but I wanted to at least try it), it seems to freeze up the computer with a never-ending code. Pressing ESC will force end the code, but obviously that isn't right.. lol
Any help is appreciated.
Here is the code that is currently working:
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Sheets("Bearing (1)").Visible Then Sheets("Index").Range("D12").Value = Sheets("Bearing (1)").Range("D2").Value
If Sheets("Bearing (2)").Visible Then Sheets("Index").Range("D13").Value = Sheets("Bearing (2)").Range("D2").Value
End Sub
Now this code has to be repeated 15 times (and possibly more in the future). So I would like to give my fingers a break if possible and simplify it to a For i = 1 to 15 type situation... but I can't seem to figure it out. Please notice that the Index sheet Range increases by 1 row for each bearing sheet (i+11). But the Bearing sheet range is always the same ("D2")
The other issue is that if I do type it all out (pain, but I wanted to at least try it), it seems to freeze up the computer with a never-ending code. Pressing ESC will force end the code, but obviously that isn't right.. lol
Any help is appreciated.
Last edited: