Takvim gelir-gider

Katılım
25 Aralık 2006
Mesajlar
109
Excel Vers. ve Dili
Excel 2007 Türkçe
Merhaba arkadaşlar;
"B","C" .. gibi kodlara göre hesaplama yapıp açıklamalara(comment) bakiye yazıyor.1.hafta,2.hafta,3.hafta.....52.hafta şeklinde yazarsam sorun yok.Fakat 52 haftayı tek tek yazdırmak yerine tek bir kod ile bu programı nasıl yaparım.
Saygılarımla
Private Sub Worksheet_change(ByVal Target As Range)
On Error Resume Next

'HESAP
Dim J As Long
Dim I As Long


With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
.EnableEvents = False
End With

'1.HAFTA
For J = 3 To 21 Step 3
For I = 3 To 10
With Cells(I, J)
.AddComment
Select Case Cells(I, J - 1)
Case "B": BANKA = BANKA + .Value
.Comment.Text Text:="BANKA:" & Format(BANKA + CEPBANKA - ÇEKİLEN, "#,##0.00 TL;-#,##0.00 TL") & "" & ""
Case "C": CEP = CEP + .Value
.Comment.Text Text:="CEP:" & Format(CEP + ÇEKİLEN - CEPBANKA, "#,##0.00 TL;-#,##0.00 TL") & ""
Case "Ç": ÇEKİLEN = ÇEKİLEN + .Value
.Comment.Text Text:="BANKA:" & Format(BANKA - ÇEKİLEN + CEPBANKA, "#,##0.00 TL;-#,##0.00 TL") & Chr(10) & _
"CEP:" & Format(CEP + ÇEKİLEN - CEPBANKA, "#,##0.00 TL;-#,##0.00 TL") & ""
Case "D": CEPBANKA = CEPBANKA + .Value
.Comment.Text Text:="BANKA:" & Format(BANKA - ÇEKİLEN + CEPBANKA, "#,##0.00 TL;-#,##0.00 TL") & Chr(10) & _
"CEP:" & Format(CEP + ÇEKİLEN - CEPBANKA, "#,##0.00 TL;-#,##0.00 TL") & ""
Case Else
.ClearComments
End Select
End With
Next I
Next J
'2.HAFTA
For J = 3 To 21 Step 3
For I = 12 To 19
With Cells(I, J)
.AddComment
Select Case Cells(I, J - 1)
Case "B": BANKA = BANKA + .Value
.Comment.Text Text:="BANKA:" & Format(BANKA + CEPBANKA - ÇEKİLEN, "#,##0.00 TL;-#,##0.00 TL") & "" & ""
Case "C": CEP = CEP + .Value
.Comment.Text Text:="CEP:" & Format(CEP + ÇEKİLEN - CEPBANKA, "#,##0.00 TL;-#,##0.00 TL") & ""
Case "Ç": ÇEKİLEN = ÇEKİLEN + .Value
.Comment.Text Text:="BANKA:" & Format(BANKA - ÇEKİLEN + CEPBANKA, "#,##0.00 TL;-#,##0.00 TL") & Chr(10) & _
"CEP:" & Format(CEP + ÇEKİLEN - CEPBANKA, "#,##0.00 TL;-#,##0.00 TL") & ""
Case "D": CEPBANKA = CEPBANKA + .Value
.Comment.Text Text:="BANKA:" & Format(BANKA - ÇEKİLEN + CEPBANKA, "#,##0.00 TL;-#,##0.00 TL") & Chr(10) & _
"CEP:" & Format(CEP + ÇEKİLEN - CEPBANKA, "#,##0.00 TL;-#,##0.00 TL") & ""
Case Else
.ClearComments
End Select
End With
Next I
Next J


'açıklamaları biçimlendirme
For Each açıklama In Range("C3:U82")
With açıklama.Comment.Shape.TextFrame
.AutoSize = True
.Characters.Font.Size = 14
End With
Next

With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.EnableEvents = True
End With

End Sub
 
Katılım
31 Aralık 2014
Mesajlar
1,845
Excel Vers. ve Dili
Excel 2010
Merhaba arkadaşlar;
"B","C" .. gibi kodlara göre hesaplama yapıp açıklamalara(comment) bakiye yazıyor.1.hafta,2.hafta,3.hafta.....52.hafta şeklinde yazarsam sorun yok.Fakat 52 haftayı tek tek yazdırmak yerine tek bir kod ile bu programı nasıl yaparım.
Merhaba
Aşağıdaki gibi deneyin

Kod:
[SIZE="1"] Private Sub Worksheet_change(ByVal Target As Range)
On Error Resume Next

'HESAP
Dim J As Long
Dim I As Long
Dim u As Long

With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
.EnableEvents = False
End With

[COLOR="red"]u = 3[/COLOR]
[COLOR="red"]For h = 1 To 52[/COLOR]
For J = 3 To 21 Step 3
For I = [COLOR="red"]u To u + 7[/COLOR]
With Cells(I, J)
.AddComment
Select Case Cells(I, J - 1)
Case "B": BANKA = BANKA + .Value
.Comment.Text Text:="BANKA:" & Format(BANKA + CEPBANKA - ÇEKİLEN, "#,##0.00 TL;-#,##0.00 TL") & "" & ""
Case "C": CEP = CEP + .Value
.Comment.Text Text:="CEP:" & Format(CEP + ÇEKİLEN - CEPBANKA, "#,##0.00 TL;-#,##0.00 TL") & ""
Case "Ç": ÇEKİLEN = ÇEKİLEN + .Value
.Comment.Text Text:="BANKA:" & Format(BANKA - ÇEKİLEN + CEPBANKA, "#,##0.00 TL;-#,##0.00 TL") & Chr(10) & _
"CEP:" & Format(CEP + ÇEKİLEN - CEPBANKA, "#,##0.00 TL;-#,##0.00 TL") & ""
Case "D": CEPBANKA = CEPBANKA + .Value
.Comment.Text Text:="BANKA:" & Format(BANKA - ÇEKİLEN + CEPBANKA, "#,##0.00 TL;-#,##0.00 TL") & Chr(10) & _
"CEP:" & Format(CEP + ÇEKİLEN - CEPBANKA, "#,##0.00 TL;-#,##0.00 TL") & ""
Case Else
.ClearComments
End Select
End With
Next I
Next J
[COLOR="Red"]u = u + 9
Next u[/COLOR]


'açıklamaları biçimlendirme
For Each açıklama In Range("C3:U82")
With açıklama.Comment.Shape.TextFrame
.AutoSize = True
.Characters.Font.Size = 14
End With
Next

With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.EnableEvents = True
End With

End Sub [/SIZE]
 
Son düzenleme:
Katılım
25 Aralık 2006
Mesajlar
109
Excel Vers. ve Dili
Excel 2007 Türkçe
Sayın Plint
Çok teşekkür ederim. Kodlar harika çalışıyor. Konuyu anlamak adına for h=1 to 52 döngüsünü neden kullanmadık. Saygılarımla
 
Katılım
31 Aralık 2014
Mesajlar
1,845
Excel Vers. ve Dili
Excel 2010
Sayın Plint
Çok teşekkür ederim. Kodlar harika çalışıyor. Konuyu anlamak adına for h=1 to 52 döngüsünü neden kullanmadık. Saygılarımla
Merhaba
Neden kullandık derseniz, siz 1.haftadan 52 .hafta ya kadar
istediğiniz için "1 to 52", ("52" yerine "20" 20. haftaya kadar)
Kolay gelsin.
 
Katılım
25 Aralık 2006
Mesajlar
109
Excel Vers. ve Dili
Excel 2007 Türkçe
Sayın Plint
52 haftayi yazdığımda kodlar çok yavaş çalışıyor
 
Üst