- Katılım
- 3 Haziran 2017
- Mesajlar
- 797
- Excel Vers. ve Dili
- 2007, 32
- Altın Üyelik Bitiş Tarihi
- 08/06/2018
Arkadaşlar,
Halit Hoca'nın verdiği bir kod ile Userform3'e rastgele bir veriyi butonla çağırabiliyorum. Ben bu işlemi aynı butonla, sırayla 3'ten 12'ye kadar olan aynı formattaki (aynı nesneleri içeriyor ve nesne isimleri aynı) userformlara çağırmak istiyorum. Bir döngü oluşturmak gerekiyor ama beceremedim.
Yardımcı olabilir misiniz? Örnek dosya ektedir.
Halit Hoca'nın verdiği bir kod ile Userform3'e rastgele bir veriyi butonla çağırabiliyorum. Ben bu işlemi aynı butonla, sırayla 3'ten 12'ye kadar olan aynı formattaki (aynı nesneleri içeriyor ve nesne isimleri aynı) userformlara çağırmak istiyorum. Bir döngü oluşturmak gerekiyor ama beceremedim.
Yardımcı olabilir misiniz? Örnek dosya ektedir.
Kod:
Private Sub CommandButton1_Click()
Set s1 = Worksheets("sayfa1")
sayi = UserForm4.ListBox1.ListCount
ReDim sayilar(sayi)
Dim Satir As Integer
For j = 1 To sayi
atla:
Randomize
Satir = Int((Rnd * sayi) + 1)
For m = 1 To sayi
If Satir = sayilar(m) Then
GoTo atla
End If
Next
sayilar(j) = Satir
'Cells(j, 3).Value = Satir
Next
a = sayilar(1) + 1
Adres = Worksheets("sayfa1").Cells(a, 1).Address
Dim Picture As Object
For Each Picture In s1.Shapes
If TypeName(s1.Shapes(Picture.Name).OLEFormat.Object) = "Picture" Then
yer = s1.Cells(Picture.BottomRightCell.Row, Picture.BottomRightCell.Column).Address
If yer = Adres Then
sut = Picture.BottomRightCell.Row
s1.Shapes(Picture.Name).Select
s1.Shapes(Picture.Name).CopyPicture
UserForm3.Image1.Picture = PastePicture
UserForm3.Label1.Caption = Cells(sut, "b")
UserForm3.Label2.Caption = Cells(sut, "c")
UserForm3.Label3.Caption = Cells(sut, "d")
UserForm3.Label4.Caption = Cells(sut, "e")
UserForm3.Label5.Caption = Cells(sut, "f")
UserForm3.Label6.Caption = Cells(sut, "g")
UserForm3.TextBox1.Text = Cells(sut, "h")
Exit For
End If
End If
Next Picture
UserForm3.Show
End Sub
Ekli dosyalar
-
51.8 KB Görüntüleme: 8
Son düzenleme: