RST.FIELDS kontrol koymak.

Katılım
14 Ocak 2005
Mesajlar
792
Excel Vers. ve Dili
Ofis 2010 2016
Altın Üyelik Bitiş Tarihi
13/03/2022
RST.FIELDS kontrol koyup şartım tutarsa sayfaya yazdırmak istiyorum aşağıda belirttiğim gibi.


Kod:
Set RST.DataSource = SQLCON.Execute(SQLText)

Do Until RST.EOF
For i = 1 To RST.RecordCount Step 1
Cells(i + 4, 1) = RST.Fields(0)
Cells(i + 4, 2) = RST.Fields(1)
Cells(i + 4, 3) = RST.Fields(2)
Cells(i + 4, 4) = RST.Fields(3)
Cells(i + 4, 5) = RST.Fields(4)
Cells(i + 4, 6) = RST.Fields(5)
Cells(i + 4, 7) = RST.Fields(6)
Cells(i + 4, 8) = RST.Fields(7)


RST.MoveNext

Next i
Loop

RST.Close

SQLCON.Close
rst.fields(5)+rest.fields.(7) toplamı 0 dan büyükse bu döngünün excel hücrelerini bilgileri yazdırmasını istiyorum

Rica etsem nasıl kurgularım.
 
Katılım
14 Ocak 2005
Mesajlar
792
Excel Vers. ve Dili
Ofis 2010 2016
Altın Üyelik Bitiş Tarihi
13/03/2022
Kod:
Set RST.DataSource = SQLCON.Execute(SQLText)

''Rows("19:38").Select
''    Selection.Delete Shift:=xlUp
''    Range("D23").Select
    
'Sadece hücre temizler
'''Range("A5:U65000").Select
'''Selection.ClearContents
'Bu Satırı komple siler
Rows("5:5000").Select
Selection.Delete Shift:=xlUp

Do Until RST.EOF
For i = 1 To RST.RecordCount Step 1
[COLOR="Red"][U][B]If RST.Fields(5) * 1 + RST.Fields(7) * 1 > 0 Then
[/B][/U][/COLOR]
Cells(i + 4, 1) = RST.Fields(0)
Cells(i + 4, 2) = RST.Fields(1)
Cells(i + 4, 3) = RST.Fields(2)
Cells(i + 4, 4) = RST.Fields(3)
Cells(i + 4, 5) = RST.Fields(4)
Cells(i + 4, 6) = RST.Fields(5)
Cells(i + 4, 7) = RST.Fields(6)
Cells(i + 4, 8) = RST.Fields(7)

[COLOR="red"][U][B]End If[/B][/U][/COLOR]

RST.MoveNext

Next i
Loop

RST.Close

SQLCON.Close


[COLOR="red"][U][B]Bossatirsil[/B][/U][/COLOR]


Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic









Kod:
Sub Bossatirsil()
LastRow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count
Application.ScreenUpdating = False
For k = LastRow To 1 Step -1
If Cells(k, 1) = "" Then Rows(k).Delete
Next k
End Sub
Sevgili arkadaşlar belki birisinin işne yarar diye buraya ekliyorum.
Benim yaptığım yöntem budur.

do until döngüsünün içine
if şartı koydum ve 5 ve 7 alanın toplamı 0 dan büyük olursa hücrelere yaz dedim.
değilse bu döngüden çık bir sonraki movenext den devam et
tabi bu şekilde boş satırlar oluşacaktı.
bunu da bossatir sil macrosu ile hallettim.
Onuda buraya koydum. Siteden buldum.

Herkese iyi çalışmalar dilerim.
 
Üst