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
"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