liste yapma

Katılım
5 Mart 2008
Mesajlar
902
Excel Vers. ve Dili
EV:EXCEL 2010-TÜRKÇE
İŞ:EXCEL 2010-TÜRKÇE
Arkdaşlar günaydın.linkteki dosyada öğretmenlerin veli görüşme gün saatleri var.Liste haline nasıl getirebilirim?

 
Merhaba,
Verdiğiniz tabloya istinaden; öğretmen, braş ve gün baz alınarak listeler hazırlatmak için 3 farklı buton/şekil ile makroları tetikleterek kullanabileceğiniz modül içine yazacağınız vba kodu:

C#:
Option Explicit

' ==============================================================================
' MODÜL: MEB Veli Randevu Çizelgesi Oluşturucu (Gün, Branş ve Öğretmen Bazlı)
' ==============================================================================

Sub GuneGoreListele()
    Dim wsSrc As Worksheet, wsOut As Worksheet
    Dim secilenGun As String, gunAdi As String
    Dim saatCol As Integer, lastRow As Long, r As Long
    Dim saatlerStr As String, saatArr() As String
    Dim s As Variant, temizSaat As String
    Dim outRow As Long, lastOutRow As Long
   
    Set wsSrc = ThisWorkbook.Sheets("Form Yanıtları 1")
   
    secilenGun = Trim(InputBox("Listelemek istediğiniz günü yazın:" & vbCrLf & _
                               "(Pazartesi, Salı, Çarşamba, Perşembe, Cuma)", _
                               "Günlük Randevu Çizelgesi", "Pazartesi"))
    If secilenGun = "" Then Exit Sub
   
    Select Case LCase(Replace(Replace(secilenGun, "İ", "i"), "I", "ı"))
        Case "pazartesi": saatCol = 4: gunAdi = "PAZARTESİ"
        Case "salı", "sali": saatCol = 6: gunAdi = "SALI"
        Case "çarşamba", "carsamba": saatCol = 8: gunAdi = "ÇARŞAMBA"
        Case "perşembe", "persembe": saatCol = 10: gunAdi = "PERŞEMBE"
        Case "cuma": saatCol = 12: gunAdi = "CUMA"
        Case Else
            MsgBox "Geçersiz gün adı girdiniz! Lütfen Pazartesi - Cuma arası bir gün yazın.", vbExclamation, "Hata"
            Exit Sub
    End Select
   
    Set wsOut = SayfaHazirla("Randevu_Çizelgesi")
   
    With wsOut
        .Range("A1:D1").Merge
        .Range("A1").Value = gunAdi & " GÜNÜ VELİ GÖRÜŞME ÇİZELGESİ"
        .Range("A1").Font.Size = 14
        .Range("A1").Font.Bold = True
        .Range("A1").Font.Color = vbWhite
        .Range("A1").Interior.Color = RGB(31, 78, 120)
        .Range("A1").HorizontalAlignment = xlCenter
        .Rows(1).RowHeight = 30
       
        .Range("A2:D2").Value = Array("SAAT", "ÖĞRETMEN ADI SOYADI", "BRANŞI / GÖREVİ", "GÖRÜŞME DURUMU / VELİ NOTU")
        With .Range("A2:D2")
            .Font.Bold = True
            .Font.Color = vbWhite
            .Interior.Color = RGB(68, 114, 196)
            .HorizontalAlignment = xlCenter
        End With
    End With
   
    lastRow = wsSrc.Cells(wsSrc.Rows.Count, 1).End(xlUp).Row
    outRow = 3
   
    For r = 2 To lastRow
        saatlerStr = Trim(CStr(wsSrc.Cells(r, saatCol).Value))
        If saatlerStr <> "" Then
            saatArr = Split(saatlerStr, ",")
            For Each s In saatArr
                temizSaat = Trim(CStr(s))
                If temizSaat <> "" Then
                    wsOut.Cells(outRow, 1).NumberFormat = "@"
                    wsOut.Cells(outRow, 1).Value = temizSaat
                    wsOut.Cells(outRow, 2).Value = Trim(CStr(wsSrc.Cells(r, 1).Value))
                    wsOut.Cells(outRow, 3).Value = Trim(CStr(wsSrc.Cells(r, 2).Value))
                    wsOut.Cells(outRow, 4).Value = ""
                    outRow = outRow + 1
                End If
            Next s
        End If
    Next r
   
    lastOutRow = outRow - 1
    If lastOutRow < 3 Then
        MsgBox gunAdi & " günü için kayıtlı randevu saati bulunamadı.", vbInformation, "Bilgi"
        Exit Sub
    End If
   
    With wsOut.Sort
        .SortFields.Clear
        .SortFields.Add Key:=wsOut.Range("A3:A" & lastOutRow), Order:=xlAscending
        .SortFields.Add Key:=wsOut.Range("B3:B" & lastOutRow), Order:=xlAscending
        .SetRange wsOut.Range("A2:D" & lastOutRow)
        .Header = xlYes
        .Apply
    End With
   
    TabloBicimlendir wsOut, "A2:D" & lastOutRow, "GUN"
    wsOut.Activate
End Sub

Sub BransaGoreListele()
    Dim wsSrc As Worksheet, wsOut As Worksheet
    Dim secilenBrans As String, kayitliBrans As String
    Dim lastRow As Long, r As Long, outRow As Long, lastOutRow As Long
    Dim bransDict As Object, bransListesi As String, k As Variant
   
    Set wsSrc = ThisWorkbook.Sheets("Form Yanıtları 1")
    Set bransDict = CreateObject("Scripting.Dictionary")
    lastRow = wsSrc.Cells(wsSrc.Rows.Count, 1).End(xlUp).Row
   
    For r = 2 To lastRow
        kayitliBrans = Trim(CStr(wsSrc.Cells(r, 2).Value))
        If kayitliBrans <> "" And Not bransDict.Exists(kayitliBrans) Then
            bransDict.Add kayitliBrans, 1
        End If
    Next r
   
    For Each k In bransDict.Keys
        bransListesi = bransListesi & "• " & k & vbCrLf
    Next k
   
    secilenBrans = Trim(InputBox("Listelemek istediğiniz branşı yazın (Tamamı için TÜMÜ yazın):" & vbCrLf & vbCrLf & _
                                 "Dosyadaki Mevcut Branşlar:" & vbCrLf & bransListesi, _
                                 "Branş Bazlı Randevu Çizelgesi", "Sınıf Öğretmenliği"))
    If secilenBrans = "" Then Exit Sub
   
    Set wsOut = SayfaHazirla("Randevu_Çizelgesi")
   
    With wsOut
        .Range("A1:G1").Merge
        .Range("A1").Value = UCase(secilenBrans) & " - HAFTALIK GÖRÜŞME SAATLERİ ÇİZELGESİ"
        .Range("A1").Font.Size = 14
        .Range("A1").Font.Bold = True
        .Range("A1").Font.Color = vbWhite
        .Range("A1").Interior.Color = RGB(31, 78, 120)
        .Range("A1").HorizontalAlignment = xlCenter
        .Rows(1).RowHeight = 30
       
        .Range("A2:G2").Value = Array("ÖĞRETMEN ADI SOYADI", "BRANŞI / GÖREVİ", "PAZARTESİ", "SALI", "ÇARŞAMBA", "PERŞEMBE", "CUMA")
        With .Range("A2:G2")
            .Font.Bold = True
            .Font.Color = vbWhite
            .Interior.Color = RGB(68, 114, 196)
            .HorizontalAlignment = xlCenter
        End With
    End With
   
    outRow = 3
    For r = 2 To lastRow
        kayitliBrans = Trim(CStr(wsSrc.Cells(r, 2).Value))
        If UCase(secilenBrans) = "TÜMÜ" Or UCase(secilenBrans) = "TUMU" Or _
           InStr(1, kayitliBrans, secilenBrans, vbTextCompare) > 0 Then
           
            wsOut.Cells(outRow, 1).Value = Trim(CStr(wsSrc.Cells(r, 1).Value))
            wsOut.Cells(outRow, 2).Value = kayitliBrans
            wsOut.Cells(outRow, 3).Value = SaatDuzenle(wsSrc.Cells(r, 4).Value)
            wsOut.Cells(outRow, 4).Value = SaatDuzenle(wsSrc.Cells(r, 6).Value)
            wsOut.Cells(outRow, 5).Value = SaatDuzenle(wsSrc.Cells(r, 8).Value)
            wsOut.Cells(outRow, 6).Value = SaatDuzenle(wsSrc.Cells(r, 10).Value)
            wsOut.Cells(outRow, 7).Value = SaatDuzenle(wsSrc.Cells(r, 12).Value)
            outRow = outRow + 1
        End If
    Next r
   
    lastOutRow = outRow - 1
    If lastOutRow < 3 Then
        MsgBox "'" & secilenBrans & "' branşına ait kayıt bulunamadı.", vbInformation, "Bilgi"
        Exit Sub
    End If
   
    With wsOut.Sort
        .SortFields.Clear
        .SortFields.Add Key:=wsOut.Range("B3:B" & lastOutRow), Order:=xlAscending
        .SortFields.Add Key:=wsOut.Range("A3:A" & lastOutRow), Order:=xlAscending
        .SetRange wsOut.Range("A2:G" & lastOutRow)
        .Header = xlYes
        .Apply
    End With
   
    TabloBicimlendir wsOut, "A2:G" & lastOutRow, "BRANS"
    wsOut.Activate
End Sub

Sub OgretmeneGoreListele()
    Dim wsSrc As Worksheet, wsOut As Worksheet
    Dim arananOgretmen As String, kayitliAd As String, bulunanAd As String, bulunanBrans As String
    Dim lastRow As Long, r As Long, hedefSatir As Long, outRow As Long, lastOutRow As Long
    Dim gunler As Variant, sutunlar As Variant, i As Integer
    Dim saatlerStr As String, saatArr() As String, s As Variant, temizSaat As String
    Dim eslesenSayisi As Integer, eslesenListesi As String
   
    Set wsSrc = ThisWorkbook.Sheets("Form Yanıtları 1")
    lastRow = wsSrc.Cells(wsSrc.Rows.Count, 1).End(xlUp).Row
   
    arananOgretmen = Trim(InputBox("Randevu çizelgesini görmek istediğiniz öğretmenin adını yazın:", _
                                   "Öğretmen Bazlı Randevu Çizelgesi"))
    If arananOgretmen = "" Then Exit Sub
   
    ' Önce tam eşleşme ara, yoksa kısmi eşleşmelere bak
    hedefSatir = 0
    eslesenSayisi = 0
    For r = 2 To lastRow
        kayitliAd = Trim(CStr(wsSrc.Cells(r, 1).Value))
        If LCase(kayitliAd) = LCase(arananOgretmen) Then
            hedefSatir = r
            eslesenSayisi = 1
            Exit For
        ElseIf InStr(1, kayitliAd, arananOgretmen, vbTextCompare) > 0 Then
            hedefSatir = r
            eslesenSayisi = eslesenSayisi + 1
            eslesenListesi = eslesenListesi & "• " & kayitliAd & " (" & wsSrc.Cells(r, 2).Value & ")" & vbCrLf
        End If
    Next r
   
    If eslesenSayisi = 0 Then
        MsgBox "'" & arananOgretmen & "' isminde bir öğretmen bulunamadı.", vbExclamation, "Bulunamadı"
        Exit Sub
    ElseIf eslesenSayisi > 1 Then
        MsgBox "Birden fazla öğretmen eşleşti. Lütfen tam adını yazın:" & vbCrLf & vbCrLf & eslesenListesi, vbInformation, "Birden Fazla Eşleşme"
        Exit Sub
    End If
   
    bulunanAd = Trim(CStr(wsSrc.Cells(hedefSatir, 1).Value))
    bulunanBrans = Trim(CStr(wsSrc.Cells(hedefSatir, 2).Value))
   
    Set wsOut = SayfaHazirla("Randevu_Çizelgesi")
   
    ' Üst Bilgi Kartı
    With wsOut
        .Range("A1:D1").Merge
        .Range("A1").Value = UCase(bulunanAd) & " - HAFTALIK VELİ GÖRÜŞME ÇİZELGESİ"
        .Range("A1").Font.Size = 14
        .Range("A1").Font.Bold = True
        .Range("A1").Font.Color = vbWhite
        .Range("A1").Interior.Color = RGB(31, 78, 120)
        .Range("A1").HorizontalAlignment = xlCenter
        .Rows(1).RowHeight = 30
       
        .Range("A2:D2").Merge
        .Range("A2").Value = "Branşı / Görevi: " & bulunanBrans
        .Range("A2").Font.Size = 11
        .Range("A2").Font.Bold = True
        .Range("A2").Font.Color = RGB(31, 78, 120)
        .Range("A2").Interior.Color = RGB(217, 225, 242)
        .Range("A2").HorizontalAlignment = xlCenter
        .Rows(2).RowHeight = 22
       
        .Range("A3:D3").Value = Array("GÜN", "SAAT", "VELİ ADI SOYADI / ÖĞRENCİ BİLGİSİ", "GÖRÜŞME NOTU / DURUM")
        With .Range("A3:D3")
            .Font.Bold = True
            .Font.Color = vbWhite
            .Interior.Color = RGB(68, 114, 196)
            .HorizontalAlignment = xlCenter
        End With
    End With
   
    gunler = Array("Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma")
    sutunlar = Array(4, 6, 8, 10, 12)
    outRow = 4
   
    ' Pazartesiden Cumaya saatleri sırayla yazdır
    For i = 0 To 4
        saatlerStr = Trim(CStr(wsSrc.Cells(hedefSatir, sutunlar(i)).Value))
        If saatlerStr <> "" Then
            saatArr = Split(saatlerStr, ",")
            ' Aynı gün içindeki saatleri küçükten büyüğe sırala
            SiralaDizi saatArr
            For Each s In saatArr
                temizSaat = Trim(CStr(s))
                If temizSaat <> "" Then
                    wsOut.Cells(outRow, 1).Value = gunler(i)
                    wsOut.Cells(outRow, 2).NumberFormat = "@"
                    wsOut.Cells(outRow, 2).Value = temizSaat
                    wsOut.Cells(outRow, 3).Value = ""
                    wsOut.Cells(outRow, 4).Value = ""
                    outRow = outRow + 1
                End If
            Next s
        End If
    Next i
   
    lastOutRow = outRow - 1
    If lastOutRow < 4 Then
        MsgBox bulunanAd & " için kayıtlı herhangi bir görüşme saati bulunamadı.", vbInformation, "Bilgi"
        Exit Sub
    End If
   
    TabloBicimlendir wsOut, "A3:D" & lastOutRow, "OGRETMEN"
    wsOut.Activate
End Sub

' --- YARDIMCI FONKSİYONLAR ---

Private Function SayfaHazirla(sayfaAdi As String) As Worksheet
    Dim ws As Worksheet
    On Error Resume Next
    Set ws = ThisWorkbook.Sheets(sayfaAdi)
    On Error GoTo 0
   
    If ws Is Nothing Then
        Set ws = ThisWorkbook.Sheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))
        ws.Name = sayfaAdi
    Else
        ws.Cells.Clear
    End If
    Set SayfaHazirla = ws
End Function

Private Function SaatDuzenle(ByVal hamMetin As Variant) As String
    Dim txt As String
    txt = Trim(CStr(hamMetin))
    If txt = "" Then
        SaatDuzenle = "-"
    Else
        SaatDuzenle = Replace(txt, ", ", vbLf)
        SaatDuzenle = Replace(SaatDuzenle, ",", vbLf)
    End If
End Function

Private Sub SiralaDizi(ByRef arr() As String)
    Dim i As Long, j As Long, gecici As String
    For i = LBound(arr) To UBound(arr) - 1
        For j = i + 1 To UBound(arr)
            If Trim(arr(i)) > Trim(arr(j)) Then
                gecici = arr(i)
                arr(i) = arr(j)
                arr(j) = gecici
            End If
        Next j
    Next i
End Sub

Private Sub TabloBicimlendir(ws As Worksheet, alan As String, modTipi As String)
    Dim rng As Range, r As Range, baslangicSatiri As Long
    Set rng = ws.Range(alan)
    baslangicSatiri = rng.Row + 1
   
    With rng
        .Borders.LineStyle = xlContinuous
        .Borders.Weight = xlThin
        .Borders.Color = RGB(180, 198, 231)
        .VerticalAlignment = xlCenter
        .WrapText = True
    End With
   
    For Each r In rng.Rows
        If r.Row >= baslangicSatiri Then
            If r.Row Mod 2 = 1 Then
                r.Interior.Color = RGB(242, 245, 249)
            Else
                r.Interior.Color = vbWhite
            End If
        End If
    Next r
   
    ws.Columns.AutoFit
    Select Case modTipi
        Case "GUN"
            ws.Columns("A").HorizontalAlignment = xlCenter
            ws.Columns("A").Font.Bold = True
            ws.Columns("D").ColumnWidth = 35
            ws.Rows.AutoFit
            ws.Rows(1).RowHeight = 32
            ws.Rows(2).RowHeight = 24
        Case "BRANS"
            ws.Range("C3:G" & rng.Rows.Count + 1).HorizontalAlignment = xlCenter
            ws.Columns("C:G").ColumnWidth = 14
            ws.Rows.AutoFit
            ws.Rows(1).RowHeight = 32
            ws.Rows(2).RowHeight = 24
        Case "OGRETMEN"
            ws.Columns("A:B").HorizontalAlignment = xlCenter
            ws.Columns("A").Font.Bold = True
            ws.Columns("B").Font.Bold = True
            ws.Columns("A").ColumnWidth = 16
            ws.Columns("B").ColumnWidth = 12
            ws.Columns("C").ColumnWidth = 32
            ws.Columns("D").ColumnWidth = 30
            ws.Rows.AutoFit
            ws.Rows(1).RowHeight = 32
            ws.Rows(2).RowHeight = 22
            ws.Rows(3).RowHeight = 24
    End Select
End Sub

*Kodlar yapay zeka tarafından yazıldı, Office 2024 ile tarafımca dosyanızda test edildi.

Umarım işinizi görür.
İyi çalışmalar.
 
İlginiz için teşekkür ederim. Ben bu modül ekleme işinden anlamam. Bunu nasıl yapacağız?
 
İlginiz için teşekkür ederim. Ben bu modül ekleme işinden anlamam. Bunu nasıl yapacağız?
Merhaba,
Verdiğiniz tabloya istinaden; öğretmen, braş ve gün baz alınarak listeler hazırlatmak için 3 farklı buton/şekil ile makroları tetikleterek kullanabileceğiniz modül içine yazacağınız vba kodu:

C#:
Option Explicit

' ==============================================================================
' MODÜL: MEB Veli Randevu Çizelgesi Oluşturucu (Gün, Branş ve Öğretmen Bazlı)
' ==============================================================================

Sub GuneGoreListele()
    Dim wsSrc As Worksheet, wsOut As Worksheet
    Dim secilenGun As String, gunAdi As String
    Dim saatCol As Integer, lastRow As Long, r As Long
    Dim saatlerStr As String, saatArr() As String
    Dim s As Variant, temizSaat As String
    Dim outRow As Long, lastOutRow As Long
  
    Set wsSrc = ThisWorkbook.Sheets("Form Yanıtları 1")
  
    secilenGun = Trim(InputBox("Listelemek istediğiniz günü yazın:" & vbCrLf & _
                               "(Pazartesi, Salı, Çarşamba, Perşembe, Cuma)", _
                               "Günlük Randevu Çizelgesi", "Pazartesi"))
    If secilenGun = "" Then Exit Sub
  
    Select Case LCase(Replace(Replace(secilenGun, "İ", "i"), "I", "ı"))
        Case "pazartesi": saatCol = 4: gunAdi = "PAZARTESİ"
        Case "salı", "sali": saatCol = 6: gunAdi = "SALI"
        Case "çarşamba", "carsamba": saatCol = 8: gunAdi = "ÇARŞAMBA"
        Case "perşembe", "persembe": saatCol = 10: gunAdi = "PERŞEMBE"
        Case "cuma": saatCol = 12: gunAdi = "CUMA"
        Case Else
            MsgBox "Geçersiz gün adı girdiniz! Lütfen Pazartesi - Cuma arası bir gün yazın.", vbExclamation, "Hata"
            Exit Sub
    End Select
  
    Set wsOut = SayfaHazirla("Randevu_Çizelgesi")
  
    With wsOut
        .Range("A1:D1").Merge
        .Range("A1").Value = gunAdi & " GÜNÜ VELİ GÖRÜŞME ÇİZELGESİ"
        .Range("A1").Font.Size = 14
        .Range("A1").Font.Bold = True
        .Range("A1").Font.Color = vbWhite
        .Range("A1").Interior.Color = RGB(31, 78, 120)
        .Range("A1").HorizontalAlignment = xlCenter
        .Rows(1).RowHeight = 30
      
        .Range("A2:D2").Value = Array("SAAT", "ÖĞRETMEN ADI SOYADI", "BRANŞI / GÖREVİ", "GÖRÜŞME DURUMU / VELİ NOTU")
        With .Range("A2:D2")
            .Font.Bold = True
            .Font.Color = vbWhite
            .Interior.Color = RGB(68, 114, 196)
            .HorizontalAlignment = xlCenter
        End With
    End With
  
    lastRow = wsSrc.Cells(wsSrc.Rows.Count, 1).End(xlUp).Row
    outRow = 3
  
    For r = 2 To lastRow
        saatlerStr = Trim(CStr(wsSrc.Cells(r, saatCol).Value))
        If saatlerStr <> "" Then
            saatArr = Split(saatlerStr, ",")
            For Each s In saatArr
                temizSaat = Trim(CStr(s))
                If temizSaat <> "" Then
                    wsOut.Cells(outRow, 1).NumberFormat = "@"
                    wsOut.Cells(outRow, 1).Value = temizSaat
                    wsOut.Cells(outRow, 2).Value = Trim(CStr(wsSrc.Cells(r, 1).Value))
                    wsOut.Cells(outRow, 3).Value = Trim(CStr(wsSrc.Cells(r, 2).Value))
                    wsOut.Cells(outRow, 4).Value = ""
                    outRow = outRow + 1
                End If
            Next s
        End If
    Next r
  
    lastOutRow = outRow - 1
    If lastOutRow < 3 Then
        MsgBox gunAdi & " günü için kayıtlı randevu saati bulunamadı.", vbInformation, "Bilgi"
        Exit Sub
    End If
  
    With wsOut.Sort
        .SortFields.Clear
        .SortFields.Add Key:=wsOut.Range("A3:A" & lastOutRow), Order:=xlAscending
        .SortFields.Add Key:=wsOut.Range("B3:B" & lastOutRow), Order:=xlAscending
        .SetRange wsOut.Range("A2:D" & lastOutRow)
        .Header = xlYes
        .Apply
    End With
  
    TabloBicimlendir wsOut, "A2:D" & lastOutRow, "GUN"
    wsOut.Activate
End Sub

Sub BransaGoreListele()
    Dim wsSrc As Worksheet, wsOut As Worksheet
    Dim secilenBrans As String, kayitliBrans As String
    Dim lastRow As Long, r As Long, outRow As Long, lastOutRow As Long
    Dim bransDict As Object, bransListesi As String, k As Variant
  
    Set wsSrc = ThisWorkbook.Sheets("Form Yanıtları 1")
    Set bransDict = CreateObject("Scripting.Dictionary")
    lastRow = wsSrc.Cells(wsSrc.Rows.Count, 1).End(xlUp).Row
  
    For r = 2 To lastRow
        kayitliBrans = Trim(CStr(wsSrc.Cells(r, 2).Value))
        If kayitliBrans <> "" And Not bransDict.Exists(kayitliBrans) Then
            bransDict.Add kayitliBrans, 1
        End If
    Next r
  
    For Each k In bransDict.Keys
        bransListesi = bransListesi & "• " & k & vbCrLf
    Next k
  
    secilenBrans = Trim(InputBox("Listelemek istediğiniz branşı yazın (Tamamı için TÜMÜ yazın):" & vbCrLf & vbCrLf & _
                                 "Dosyadaki Mevcut Branşlar:" & vbCrLf & bransListesi, _
                                 "Branş Bazlı Randevu Çizelgesi", "Sınıf Öğretmenliği"))
    If secilenBrans = "" Then Exit Sub
  
    Set wsOut = SayfaHazirla("Randevu_Çizelgesi")
  
    With wsOut
        .Range("A1:G1").Merge
        .Range("A1").Value = UCase(secilenBrans) & " - HAFTALIK GÖRÜŞME SAATLERİ ÇİZELGESİ"
        .Range("A1").Font.Size = 14
        .Range("A1").Font.Bold = True
        .Range("A1").Font.Color = vbWhite
        .Range("A1").Interior.Color = RGB(31, 78, 120)
        .Range("A1").HorizontalAlignment = xlCenter
        .Rows(1).RowHeight = 30
      
        .Range("A2:G2").Value = Array("ÖĞRETMEN ADI SOYADI", "BRANŞI / GÖREVİ", "PAZARTESİ", "SALI", "ÇARŞAMBA", "PERŞEMBE", "CUMA")
        With .Range("A2:G2")
            .Font.Bold = True
            .Font.Color = vbWhite
            .Interior.Color = RGB(68, 114, 196)
            .HorizontalAlignment = xlCenter
        End With
    End With
  
    outRow = 3
    For r = 2 To lastRow
        kayitliBrans = Trim(CStr(wsSrc.Cells(r, 2).Value))
        If UCase(secilenBrans) = "TÜMÜ" Or UCase(secilenBrans) = "TUMU" Or _
           InStr(1, kayitliBrans, secilenBrans, vbTextCompare) > 0 Then
          
            wsOut.Cells(outRow, 1).Value = Trim(CStr(wsSrc.Cells(r, 1).Value))
            wsOut.Cells(outRow, 2).Value = kayitliBrans
            wsOut.Cells(outRow, 3).Value = SaatDuzenle(wsSrc.Cells(r, 4).Value)
            wsOut.Cells(outRow, 4).Value = SaatDuzenle(wsSrc.Cells(r, 6).Value)
            wsOut.Cells(outRow, 5).Value = SaatDuzenle(wsSrc.Cells(r, 8).Value)
            wsOut.Cells(outRow, 6).Value = SaatDuzenle(wsSrc.Cells(r, 10).Value)
            wsOut.Cells(outRow, 7).Value = SaatDuzenle(wsSrc.Cells(r, 12).Value)
            outRow = outRow + 1
        End If
    Next r
  
    lastOutRow = outRow - 1
    If lastOutRow < 3 Then
        MsgBox "'" & secilenBrans & "' branşına ait kayıt bulunamadı.", vbInformation, "Bilgi"
        Exit Sub
    End If
  
    With wsOut.Sort
        .SortFields.Clear
        .SortFields.Add Key:=wsOut.Range("B3:B" & lastOutRow), Order:=xlAscending
        .SortFields.Add Key:=wsOut.Range("A3:A" & lastOutRow), Order:=xlAscending
        .SetRange wsOut.Range("A2:G" & lastOutRow)
        .Header = xlYes
        .Apply
    End With
  
    TabloBicimlendir wsOut, "A2:G" & lastOutRow, "BRANS"
    wsOut.Activate
End Sub

Sub OgretmeneGoreListele()
    Dim wsSrc As Worksheet, wsOut As Worksheet
    Dim arananOgretmen As String, kayitliAd As String, bulunanAd As String, bulunanBrans As String
    Dim lastRow As Long, r As Long, hedefSatir As Long, outRow As Long, lastOutRow As Long
    Dim gunler As Variant, sutunlar As Variant, i As Integer
    Dim saatlerStr As String, saatArr() As String, s As Variant, temizSaat As String
    Dim eslesenSayisi As Integer, eslesenListesi As String
  
    Set wsSrc = ThisWorkbook.Sheets("Form Yanıtları 1")
    lastRow = wsSrc.Cells(wsSrc.Rows.Count, 1).End(xlUp).Row
  
    arananOgretmen = Trim(InputBox("Randevu çizelgesini görmek istediğiniz öğretmenin adını yazın:", _
                                   "Öğretmen Bazlı Randevu Çizelgesi"))
    If arananOgretmen = "" Then Exit Sub
  
    ' Önce tam eşleşme ara, yoksa kısmi eşleşmelere bak
    hedefSatir = 0
    eslesenSayisi = 0
    For r = 2 To lastRow
        kayitliAd = Trim(CStr(wsSrc.Cells(r, 1).Value))
        If LCase(kayitliAd) = LCase(arananOgretmen) Then
            hedefSatir = r
            eslesenSayisi = 1
            Exit For
        ElseIf InStr(1, kayitliAd, arananOgretmen, vbTextCompare) > 0 Then
            hedefSatir = r
            eslesenSayisi = eslesenSayisi + 1
            eslesenListesi = eslesenListesi & "• " & kayitliAd & " (" & wsSrc.Cells(r, 2).Value & ")" & vbCrLf
        End If
    Next r
  
    If eslesenSayisi = 0 Then
        MsgBox "'" & arananOgretmen & "' isminde bir öğretmen bulunamadı.", vbExclamation, "Bulunamadı"
        Exit Sub
    ElseIf eslesenSayisi > 1 Then
        MsgBox "Birden fazla öğretmen eşleşti. Lütfen tam adını yazın:" & vbCrLf & vbCrLf & eslesenListesi, vbInformation, "Birden Fazla Eşleşme"
        Exit Sub
    End If
  
    bulunanAd = Trim(CStr(wsSrc.Cells(hedefSatir, 1).Value))
    bulunanBrans = Trim(CStr(wsSrc.Cells(hedefSatir, 2).Value))
  
    Set wsOut = SayfaHazirla("Randevu_Çizelgesi")
  
    ' Üst Bilgi Kartı
    With wsOut
        .Range("A1:D1").Merge
        .Range("A1").Value = UCase(bulunanAd) & " - HAFTALIK VELİ GÖRÜŞME ÇİZELGESİ"
        .Range("A1").Font.Size = 14
        .Range("A1").Font.Bold = True
        .Range("A1").Font.Color = vbWhite
        .Range("A1").Interior.Color = RGB(31, 78, 120)
        .Range("A1").HorizontalAlignment = xlCenter
        .Rows(1).RowHeight = 30
      
        .Range("A2:D2").Merge
        .Range("A2").Value = "Branşı / Görevi: " & bulunanBrans
        .Range("A2").Font.Size = 11
        .Range("A2").Font.Bold = True
        .Range("A2").Font.Color = RGB(31, 78, 120)
        .Range("A2").Interior.Color = RGB(217, 225, 242)
        .Range("A2").HorizontalAlignment = xlCenter
        .Rows(2).RowHeight = 22
      
        .Range("A3:D3").Value = Array("GÜN", "SAAT", "VELİ ADI SOYADI / ÖĞRENCİ BİLGİSİ", "GÖRÜŞME NOTU / DURUM")
        With .Range("A3:D3")
            .Font.Bold = True
            .Font.Color = vbWhite
            .Interior.Color = RGB(68, 114, 196)
            .HorizontalAlignment = xlCenter
        End With
    End With
  
    gunler = Array("Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma")
    sutunlar = Array(4, 6, 8, 10, 12)
    outRow = 4
  
    ' Pazartesiden Cumaya saatleri sırayla yazdır
    For i = 0 To 4
        saatlerStr = Trim(CStr(wsSrc.Cells(hedefSatir, sutunlar(i)).Value))
        If saatlerStr <> "" Then
            saatArr = Split(saatlerStr, ",")
            ' Aynı gün içindeki saatleri küçükten büyüğe sırala
            SiralaDizi saatArr
            For Each s In saatArr
                temizSaat = Trim(CStr(s))
                If temizSaat <> "" Then
                    wsOut.Cells(outRow, 1).Value = gunler(i)
                    wsOut.Cells(outRow, 2).NumberFormat = "@"
                    wsOut.Cells(outRow, 2).Value = temizSaat
                    wsOut.Cells(outRow, 3).Value = ""
                    wsOut.Cells(outRow, 4).Value = ""
                    outRow = outRow + 1
                End If
            Next s
        End If
    Next i
  
    lastOutRow = outRow - 1
    If lastOutRow < 4 Then
        MsgBox bulunanAd & " için kayıtlı herhangi bir görüşme saati bulunamadı.", vbInformation, "Bilgi"
        Exit Sub
    End If
  
    TabloBicimlendir wsOut, "A3:D" & lastOutRow, "OGRETMEN"
    wsOut.Activate
End Sub

' --- YARDIMCI FONKSİYONLAR ---

Private Function SayfaHazirla(sayfaAdi As String) As Worksheet
    Dim ws As Worksheet
    On Error Resume Next
    Set ws = ThisWorkbook.Sheets(sayfaAdi)
    On Error GoTo 0
  
    If ws Is Nothing Then
        Set ws = ThisWorkbook.Sheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))
        ws.Name = sayfaAdi
    Else
        ws.Cells.Clear
    End If
    Set SayfaHazirla = ws
End Function

Private Function SaatDuzenle(ByVal hamMetin As Variant) As String
    Dim txt As String
    txt = Trim(CStr(hamMetin))
    If txt = "" Then
        SaatDuzenle = "-"
    Else
        SaatDuzenle = Replace(txt, ", ", vbLf)
        SaatDuzenle = Replace(SaatDuzenle, ",", vbLf)
    End If
End Function

Private Sub SiralaDizi(ByRef arr() As String)
    Dim i As Long, j As Long, gecici As String
    For i = LBound(arr) To UBound(arr) - 1
        For j = i + 1 To UBound(arr)
            If Trim(arr(i)) > Trim(arr(j)) Then
                gecici = arr(i)
                arr(i) = arr(j)
                arr(j) = gecici
            End If
        Next j
    Next i
End Sub

Private Sub TabloBicimlendir(ws As Worksheet, alan As String, modTipi As String)
    Dim rng As Range, r As Range, baslangicSatiri As Long
    Set rng = ws.Range(alan)
    baslangicSatiri = rng.Row + 1
  
    With rng
        .Borders.LineStyle = xlContinuous
        .Borders.Weight = xlThin
        .Borders.Color = RGB(180, 198, 231)
        .VerticalAlignment = xlCenter
        .WrapText = True
    End With
  
    For Each r In rng.Rows
        If r.Row >= baslangicSatiri Then
            If r.Row Mod 2 = 1 Then
                r.Interior.Color = RGB(242, 245, 249)
            Else
                r.Interior.Color = vbWhite
            End If
        End If
    Next r
  
    ws.Columns.AutoFit
    Select Case modTipi
        Case "GUN"
            ws.Columns("A").HorizontalAlignment = xlCenter
            ws.Columns("A").Font.Bold = True
            ws.Columns("D").ColumnWidth = 35
            ws.Rows.AutoFit
            ws.Rows(1).RowHeight = 32
            ws.Rows(2).RowHeight = 24
        Case "BRANS"
            ws.Range("C3:G" & rng.Rows.Count + 1).HorizontalAlignment = xlCenter
            ws.Columns("C:G").ColumnWidth = 14
            ws.Rows.AutoFit
            ws.Rows(1).RowHeight = 32
            ws.Rows(2).RowHeight = 24
        Case "OGRETMEN"
            ws.Columns("A:B").HorizontalAlignment = xlCenter
            ws.Columns("A").Font.Bold = True
            ws.Columns("B").Font.Bold = True
            ws.Columns("A").ColumnWidth = 16
            ws.Columns("B").ColumnWidth = 12
            ws.Columns("C").ColumnWidth = 32
            ws.Columns("D").ColumnWidth = 30
            ws.Rows.AutoFit
            ws.Rows(1).RowHeight = 32
            ws.Rows(2).RowHeight = 22
            ws.Rows(3).RowHeight = 24
    End Select
End Sub

*Kodlar yapay zeka tarafından yazıldı, Office 2024 ile tarafımca dosyanızda test edildi.

Umarım işinizi görür.
İyi çalışmalar.
 
İlginiz için teşekkür ederim. Ben bu modül ekleme işinden anlamam. Bunu nasıl yapacağız?
Merhaba, siz paylaşmış olduğunuz excel dosyasını Google Sheet' mi alıyorsunuz?
Eğer bu işlemi Google Sheet ortamında yapacaksanız daha farklı bir çalışma gerekir?
 
İlginiz için teşekkür ederim. Ben bu modül ekleme işinden anlamam. Bunu nasıl yapacağız?
Merhaba, geçmiş konularınızda makro içeren içeriklere yer verildiğinden nasıl yapıldığını anlatma gereği duymamıştım.

- MS Excel ile dosyanızı açın,
- Altta sayfa adının üzerinde mouse ile sağ tuşa basıp > Kod Görüntüle ya da ALT+F11 tuşlarına basarak VBA ara yüzünü açın.
- Solda dosya adınızı içeren ağaç menüde mouse ile sağ tuşa basıp > insert > module seçilerek sağ tarafta açılan beyaz alana vermiş olduğum kodları yapıştırın.
- Dosyanıza geçin
- 3 tane şekil ekleyin herhangi bir yere
- Her bir şekil üzerinde mouse ile sağ tuş > Makro Ata ile açılan pencereden seçimleri yapın.
- Dosyanızı Farklı Kaydet ile Makro İçerebilen dosya olarak kaydedin.

Kontrol için, farklı makrolar atadığınız şekillere basarak test edin.

İyi çalışmalar.
 
Geri
Üst