Userformun Sayfa1 De ÇaliŞmasi

Katılım
11 Ağustos 2005
Mesajlar
239
ARKADAŞLAR AŞAĞIDAKİ KODUN HER ZAMAN SAYFA1 DE ÇALIŞMASINI NASIL YAPARIM
TEŞEKKÜRLER

Private Sub CommandButton1_Click()
For a = 1 To 8
If Controls("textbox" & a) = "" Then
MsgBox "VERİ GİRİŞİ EKSİKTİR"
Exit Sub
End If
Next
sonsat = [a65536].End(3).Row + 1
Cells(sonsat, 1) = sonsat - 1
Cells(sonsat, 2) = TextBox1
Cells(sonsat, 3) = TextBox2
Cells(sonsat, 4) = TextBox3
Cells(sonsat, 5) = TextBox4
Cells(sonsat, 6) = TextBox5
Cells(sonsat, 7) = TextBox6
Cells(sonsat, 8) = TextBox7
Cells(sonsat, 9) = CLng(CDate(TextBox8))
UserForm_Initialize
ListBox1.ListIndex = sonsat - 2
End Sub
Private Sub CommandButton2_Click()
sor = MsgBox("Değiştirmek istediğinizden eminmisiniz?", vbYesNo)
If sor = vbNo Then Exit Sub
sonsat = ListBox1.ListIndex + 2
Cells(sonsat, 2) = TextBox1
Cells(sonsat, 3) = TextBox2
Cells(sonsat, 4) = TextBox3
Cells(sonsat, 5) = TextBox4
Cells(sonsat, 6) = TextBox5
Cells(sonsat, 7) = TextBox6
Cells(sonsat, 8) = TextBox7
Cells(sonsat, 9) = CLng(CDate(TextBox8))
ListBox1.RowSource = "B2:I" & [a65536].End(3).Row
MsgBox "DEĞİŞİKLİK YAPILMIŞTIR"
End Sub
Private Sub CommandButton3_Click()
sor = MsgBox("Silmek istediğinizden eminmisiniz?", vbYesNo)
If sor = vbNo Then Exit Sub
sat = ListBox1.ListIndex + 2
Range("B" & sat & ":I" & sat).Delete
[a65536].End(3).ClearContents
Range("a2:j" & [a65536].End(3).Row).Interior.ColorIndex = xlNone
UserForm_Initialize
CommandButton5_Click
MsgBox "SEÇİLEN VERİ SİLİNMİŞTİR"
End Sub
Private Sub CommandButton5_Click()
CommandButton1.Enabled = True
CommandButton2.Enabled = False
CommandButton3.Enabled = False
For a = 1 To 8
Controls("textbox" & a) = ""
Next
ListBox1.ListIndex = -1
End Sub
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
For a = 0 To 6
Controls("textbox" & a + 1) = ListBox1.Column(a)
Next
TextBox8 = Format(ListBox1.Column(7), "dd.mm.yyyy")
sat = ListBox1.ListIndex + 2
Range("A" & sat & ":I" & sat).Interior.ColorIndex = 6
CommandButton1.Enabled = False
CommandButton2.Enabled = True
CommandButton3.Enabled = True
End Sub
Private Sub TextBox8_Exit(ByVal Cancel As MSForms.ReturnBoolean)
TextBox8 = Format(TextBox8, "dd.mm.yyyy")
End Sub
Private Sub UserForm_Initialize()
ListBox1.ColumnCount = 8
ListBox1.ColumnWidths = "50;80;70;60;50;70;50;50"
ListBox1.RowSource = "B2:I" & [a65536].End(3).Row
CommandButton2.Enabled = False
CommandButton3.Enabled = False
Me.Top = 40
Me.Left = 80
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Range("a2:j65536").Interior.ColorIndex = xlNone
End Sub
 
Katılım
2 Mart 2005
Mesajlar
2,960
Excel Vers. ve Dili
ev: Ofis 2007- Win Xp
iş: Ofis 2010- Win Vista
Kod:
................
Dim S1 As Worksheet
Set S1 = Sheets("Sayfa1")
....................
'diğer kodlarıda
sonsat = [color="green"]s1.[/color][a65536].End(3).Row + 1
[color="green"]s1.[/color]Cells(sonsat, 1)
...............
'şeklinde düzenleyiniz.
 
Katılım
11 Ağustos 2005
Mesajlar
239
ARKADAŞIM BEN PEK ANLAMADIM
Dim S1 As Worksheet
Set S1 = Sheets("Sayfa1")

NEREŞE YAZILAÇAK
 
Katılım
2 Mart 2005
Mesajlar
2,960
Excel Vers. ve Dili
ev: Ofis 2007- Win Xp
iş: Ofis 2010- Win Vista
Kod:
Private Sub CommandButton1_Click()
[color="red"]
Dim S1 As Worksheet
Set S1 = Sheets("Sayfa1")[/color]

For a = 1 To 8
If Controls("textbox" & a) = "" Then
MsgBox "VERİ GİRİŞİ EKSİKTİR"
Exit Sub
End If
Next

sonsat = [color="red"]s1.[/color][a65536].End(3).Row + 1
[color="red"]s1.[/color]Cells(sonsat, 1) = sonsat - 1
[color="red"]s1.[/color]Cells(sonsat, 2) = TextBox1
[color="red"]s1.[/color]Cells(sonsat, 3) = TextBox2
[color="red"]s1.[/color]Cells(sonsat, 4) = TextBox3
[color="red"]s1.[/color]Cells(sonsat, 5) = TextBox4
[color="red"]s1.[/color]Cells(sonsat, 6) = TextBox5
[color="red"]s1.[/color]Cells(sonsat, 7) = TextBox6
[color="red"]s1.[/color]Cells(sonsat, 8) = TextBox7
[color="red"]s1.[/color]Cells(sonsat, 9) = CLng(CDate(TextBox8))
UserForm_Initialize
ListBox1.ListIndex = sonsat - 2
End Sub

Gibi oluyor....
Command butonların tamamının altına kopyalayacaksınız ilk iki satırı
Sayfa1 den almasını istediğiniz Range veya Cells olaylarının önünede s1. koyacaksınız
 
Katılım
2 Mart 2005
Mesajlar
2,960
Excel Vers. ve Dili
ev: Ofis 2007- Win Xp
iş: Ofis 2010- Win Vista
çalışma kitabını eklermisin...kvp başlamadan halledelim şlşunu
 
Katılım
2 Mart 2005
Mesajlar
2,960
Excel Vers. ve Dili
ev: Ofis 2007- Win Xp
iş: Ofis 2010- Win Vista
buyrun herhalde tamam
bazı yerlerde gereksiz s1 i set emişsiniz.
range olayında önce
S1.Select Yazmak lazım en başa onu ben unuttum kusura bakma
 
Üst