Hi
Try this worksheet activation macro. Right click on the Machine #1 tab, select view code, and paste in the code below. Now when you activate that tab, it will clear out any existing data, and bring in the relevant tool.
Private Sub Worksheet_Activate()
Dim DataSH As Worksheet
Set DataSH = Sheets("Yearly to Daily")
lastrow = 4 + WorksheetFunction.CountA(DataSH.Range("C5:C54"))
lastcol = DataSH.Cells(4, Columns.Count).End(xlToLeft).Column
outrow = 2
'clear out any existing entries
For i = 6 To 42 Step 4
Cells(i, 2).Resize(4, 1).ClearContents
Next i
For i = 5 To lastrow
For j = 27 To lastcol
If DataSH.Cells(i, j) = Range("B1") Then
outrow = outrow + 4
Cells(outrow, 2).Value = DataSH.Cells(i, 3).Value
Exit For
End If
Next j
Next i
End Sub
rylo
Bookmarks