• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

makroda satır değiştirmek

Katılım
24 Aralık 2010
Mesajlar
79
Excel Vers. ve Dili
2003
Merhaba arkadaşlar; Aşağıdaki kod A1'den başlamak kaydıyla sırayla B1,C1...vb. 10 tane birbirinden farklı rastgele sayılar üretiyor.
Bunu A5'ten başlamak kaydıyla nasıl yapabiliriz?

SÜTUN = [IV1].End(1).Column
If SÜTUN = 10 Then Exit Sub
BAŞLA:
sayi = Int((10 * Rnd) + 1)
If WorksheetFunction.CountIf(Range(Cells(1, 1), Cells(1, SÜTUN + 1)), sayi) > 0 Or sayi = 0 Then GoTo BAŞLA
If Cells(1, SÜTUN) <> "" Then
Cells(1, SÜTUN + 1) = sayi
Else
Cells(1, SÜTUN) = sayi
End If
 
Son düzenleme:
If Cells(1, SÜTUN) <> "" Then
Cells(1, SÜTUN + 1) = sayi
Else
Cells(1, SÜTUN) = sayi

If Cells(5, SÜTUN) <> "" Then
Cells(5, SÜTUN + 1) = sayi
Else
Cells(5, SÜTUN) = sayi
şeklinde değiştiriniz.
 
İlgilendiğiniz için teşekkür ederim; ama 5 satırın A5 hücresinde sayıyı ürettikten sonra B5'e geçiyor sayıyı üretiyor; ama C5'e geçmiyor; butona tekrar bastığımda B5'te üretiyor sayıyı.
 
Kodu
SÜTUN = [IV5].End(1).Column
If SÜTUN = 10 Then Exit Sub
BAŞLA:
sayi = Int((10 * Rnd) + 1)
If WorksheetFunction.CountIf(Range(Cells(5, 1), Cells(5, SÜTUN + 1)), sayi) > 0 Or sayi = 0 Then GoTo BAŞLA
If Cells(5, SÜTUN) <> "" Then
Cells(5, SÜTUN + 1) = sayi
Else
Cells(5, SÜTUN) = sayi
End If

şeklinde değiştiriniz.
 
Alternatif olarak kod

Kod:
SÜTUN = [IV[COLOR="Red"]5[/COLOR]].End(1).Column
If SÜTUN = 10 Then Exit Sub
BAŞLA:
sayi = Int((10 * Rnd) + 1)
If WorksheetFunction.CountIf(Range(Cells([COLOR="red"]5[/COLOR], 1), Cells([COLOR="red"]5[/COLOR], SÜTUN + 1)), sayi) > 0 Or sayi = 0 Then GoTo BAŞLA
If Cells([COLOR="red"]5[/COLOR], SÜTUN) <> "" Then
Cells([COLOR="red"]5[/COLOR], SÜTUN + 1) = sayi
Else
Cells([COLOR="red"]5[/COLOR], SÜTUN) = sayi
End If
 
Geri
Üst