Private Sub Workbook_Open()
x = 1
While Cells(x, 2) <> Empty
datum = Cells(x, 2) + Str(Cells(x, 1)) + "," + Str(Cells(x, 3))
If Date = CDate(datum) Then
'nalezena shoda
mesic = Cells(x, 2)
sl_A = Cells(x, 1)
sl_B = Cells(x, 2)
sl_C = Cells(x, 3)
sl_D = Cells(x, 4)
sl_E = Cells(x, 5)
sl_F = Cells(x, 6)
sl_G = Cells(x, 7)
sl_H = Cells(x, 8)
sl_I = Cells(x, 9)
sl_J = Cells(x, 10)
y = 3
While Sheets(mesic).Cells(y, 1) <> Empty
y = y + 1
Wend
Sheets(mesic).Cells(y, 1) = sl_A
Sheets(mesic).Cells(y, 2) = sl_B
Sheets(mesic).Cells(y, 3) = sl_C
Sheets(mesic).Cells(y, 4) = sl_D
Sheets(mesic).Cells(y, 5) = sl_E
Sheets(mesic).Cells(y, 6) = sl_F
Sheets(mesic).Cells(y, 7) = sl_G
Sheets(mesic).Cells(y, 8) = sl_H
Sheets(mesic).Cells(y, 9) = sl_I
Sheets(mesic).Cells(y, 10) = sl_J
End If
x = x + 1
Wend
End Sub
Samozřejmě uloženo v ThisWorkboks.
Popis snad ani není nutný, ale učesat se to dá určitě.
Nedostatky:
neřešil jsem vícenásobné otevření sešitu (opakované zapisování položek), ....
Navrhuji např. do sloupce K na listu "trvalé platby" zadávat hodnotu 1 při zápisu položky a tyto pak již dále nezpracovávat.
Změněné pak tedy:
Private Sub Workbook_Open()
Sheets("trvalé platby").Select
x = 1
While Cells(x, 2) <> Empty
datum = Cells(x, 2) + Str(Cells(x, 1)) + "," + Str(Cells(x, 3))
If Date = CDate(datum) Then
'nalezena shoda
mesic = Cells(x, 2)
If Cells(x, 11) <> 1 Then ' nebo <1
sl_A = Cells(x, 1)
sl_B = Cells(x, 2)
sl_C = Cells(x, 3)
sl_D = Cells(x, 4)
sl_E = Cells(x, 5)
sl_F = Cells(x, 6)
sl_G = Cells(x, 7)
sl_H = Cells(x, 8)
sl_I = Cells(x, 9)
sl_J = Cells(x, 10)
y = 3
While Sheets(mesic).Cells(y, 1) <> Empty
y = y + 1
Wend
Sheets(mesic).Cells(y, 1) = sl_A
Sheets(mesic).Cells(y, 2) = sl_B
Sheets(mesic).Cells(y, 3) = sl_C
Sheets(mesic).Cells(y, 4) = sl_D
Sheets(mesic).Cells(y, 5) = sl_E
Sheets(mesic).Cells(y, 6) = sl_F
Sheets(mesic).Cells(y, 7) = sl_G
Sheets(mesic).Cells(y, 8) = sl_H
Sheets(mesic).Cells(y, 9) = sl_I
Sheets(mesic).Cells(y, 10) = sl_J
Cells(x, 11) = 1
End If
End If
x = x + 1
Wend
End Sub
Loncitovat