Textboxları değişken olarak atamak

Katılım
24 Şubat 2006
Mesajlar
265
Excel Vers. ve Dili
xp 2003 Türkçe
Merhaba,
Aşağıdaki kodlarla Userformun üzerindeki TextBoxları değişken olarak atamak istedim. Ama başaramadım. Örnek dosya ektedir. Açıklama gerekirse ayrıca yazacağım.
Amaç: TextBoxların üzerindeki değerleri haftanın günlerine dağıtmak...
Selamlar
Kod:
Private Sub CommandButton4_Click()
Range("G4:u13").Value = Null
For Each nesne In Controls
If TypeName(nesne) = "textbox" Then
nesne = n
End If
For X = 1 To 5
For i = 7 To 22
If Cells(2, i).Value = "Pazartesi" Then Cells(5, i).Value = Mid(n, 1, 1)
If Cells(2, i).Value = "Salı" Then Cells(5, i).Value = Mid(n, 2, 1)
If Cells(2, i).Value = "Çarşamba" Then Cells(5, i).Value = Mid(n, 3, 1)
If Cells(2, i).Value = "Perşembe" Then Cells(5, i).Value = Mid(n, 4, 1)
If Cells(2, i).Value = "Cuma" Then Cells(5, i).Value = Mid(n, 5, 1)
If Cells(2, i).Value = "Cumartesi" Then Cells(5, i).Value = "X"
If Cells(2, i).Value = "Pazar" Then Cells(5, i).Value = "X"
Next i
Next X
Next nesne
End Sub
 

Ekli dosyalar

Son düzenleme:
Katılım
24 Şubat 2006
Mesajlar
265
Excel Vers. ve Dili
xp 2003 Türkçe
Koları değiştirdim. Tatil günlerini işaretliyor. Ama Text kutularındakini yazmıyor???
dosyayı da yeniledim.
Kod:
Range("G4:u13").Value = Null

For X = 1 To 5
For i = 7 To 22
For y = 4 To 13
For Each nesne In Controls
If TypeName(nesne) = "TextBox" Then
nesne = n
End If
If Cells(2, i).Value = "Pazartesi" Then Cells(y, i).Value = Mid(n, 1, 1)
If Cells(2, i).Value = "Salı" Then Cells(y, i).Value = Mid(n, 2, 1)
If Cells(2, i).Value = "Çarşamba" Then Cells(y, i).Value = Mid(n, 3, 1)
If Cells(2, i).Value = "Perşembe" Then Cells(y, i).Value = Mid(n, 4, 1)
If Cells(2, i).Value = "Cuma" Then Cells(y, i).Value = Mid(n, 5, 1)
If Cells(2, i).Value = "Cumartesi" Then Cells(y, i).Value = "X"
If Cells(2, i).Value = "Pazar" Then Cells(y, i).Value = "X"
Next nesne
Next y
Next i
Next X

End Sub
 

Orion1

Uzman
Uzman
Katılım
1 Mart 2005
Mesajlar
22,239
Excel Vers. ve Dili
Win7 Home Basic TR 64 Bit

Ofis-2010-TR 32 Bit
Dosyanız ekte.:cool:
Kod:
Private Sub CommandButton4_Click()
Dim nesne As Object, i As Byte, sat As Byte, sut As Byte
Dim harf As Variant
Range("G4:u13").Value = Null
sat = 4
For Each nesne In Me.Controls
    sut = 7
    If TypeName(nesne) = "TextBox" Then
        For i = 7 To 21
            If Cells(2, sut).Value = "Cumartesi" Or _
            Cells(2, sut).Value = "Pazar" Then
                Cells(sat, sut).Value = "X"
                GoTo atla
            End If
            If Cells(2, sut).Value = "Pazartesi" Then harf = 1
            If Cells(2, sut).Value = "Salı" Then harf = 2
            If Cells(2, sut).Value = "Çarşamba" Then harf = 3
            If Cells(2, sut).Value = "Perşembe" Then harf = 4
            If Cells(2, sut).Value = "Cuma" Then harf = 5
            Cells(sat, sut).Value = Mid(nesne.Value, harf, 1)
atla:
            sut = sut + 1
        Next i
        sat = sat + 1
    End If
Next nesne
End Sub
 

Ekli dosyalar

Katılım
24 Şubat 2006
Mesajlar
265
Excel Vers. ve Dili
xp 2003 Türkçe
Sevgili Evren Gizlen,
Değişken sayısı arttıkça kafam da aynı oranda karıştı. :) Çözümün için çok teşekkür ediyorum. Sağol...
 
Üst