Option Explicit Function Saberi(Rng As Range) Dim Sit As Worksheet Dim ImeSita As String, ImeCelije As String Dim Poz As Integer, Sifra As Integer Dim Red As Range Dim Vrijednost As Integer Dim AktivniRed As Integer AktivniRed = ActiveCell.Row Const siti = "JanuaryFebruaryMarchAprilMayJuneJuly AugustSeptemberOctoberNovemberDecemberJanuary" Set Red = ActiveSheet.Cells(AktivniRed, 1) Sifra = Red For Each Sit In Worksheets ImeSita = Sit.Name Poz = InStr(1, siti, ImeSita, vbBinaryCompare) If Poz > 0 Then Vrijednost = Vrijednost + Nadji_Vrijednost(ImeSita, Rng, Sifra) End If Next Sit Saberi = Vrijednost End Function Function Nadji_Vrijednost(ImeS As String, Rn As Range, Sifra As Integer) As Integer Dim Sit As Worksheet Dim Red As Range, RedB As Integer Dim CEL As Range, R As Range Dim a a = Rn.Address Set Sit = Worksheets(ImeS) Sit.Activate Set R = Sit.Range(a) For Each Red In R.Rows If Red = Sifra Then RedB = Red.Cells.Row Set CEL = Sit.Cells(RedB, 34) Nadji_Vrijednost = CEL.Cells End If Next Red End Function