
Sub aggiornaMastro()
Dim fgDa As Worksheet, fgA As Worksheet
Dim Ur As Integer, Ctg As Integer, deb As Double, cre As Double
Set fgDa = Worksheets("Libro giornale")
Set fgA = Worksheets("Libro mastro")
Ur = fgDa.Cells(65536, 2).End(xlUp).Row
For r = 7 To Ur
'MsgBox ("Riga " & r)
If Cells(r, 2).Value = 9 Then
deb = Cells(r, 5).Value
cre = Cells(r, 6).Value
Call MandaInNove(fgA, deb, cre)
End If
Next
End Sub
Sub MandaInNove(fgA As Worksheet, deb As Double, cre As Double)
MsgBox ("MANDO IN NOVE : " & " " & deb & " " & cre)
'fgA.Range("nove").Select 'NON FUNZIONA !
Sheets(fgA).Select
Range("nove").Select 'NON FUNZIONA NEMMENO QUESTO !
MsgBox ("controllo cella destinazione")
End Sub |
Sub aggiornaMastro()
Dim fgDa As Worksheet, fgA As Worksheet
Dim Ur As Integer, Ctg As Integer, deb As Double, cre As Double
Set fgDa = Worksheets("Libro giornale")
Set fgA = Worksheets("Libro mastro")
Ur = fgDa.Cells(65536, 2).End(xlUp).Row
For r = 7 To Ur
'MsgBox ("Riga " & r)
If Cells(r, 2).Value = 9 Then
deb = Cells(r, 5).Value
cre = Cells(r, 6).Value
Call MandaInNove(fgA, deb, cre)
End If
Next
End Sub
Sub MandaInNove(fgA As Worksheet, deb As Double, cre As Double)
' (non serve più) MsgBox ("MANDO IN NOVE : " & " " & deb & " " & cre)
fgA.Select
fgA.Range("nove").End(xlDown).Offset(1, 0).Select
' (non serve più) MsgBox ("controllo cella destinazione")
ActiveCell.Value = deb
ActiveCell.Offset(0, 1).Value = cre
End Sub
|
Sub aggiornaMastro()
Dim fgDa As Worksheet, fgA As Worksheet
Dim Ur As Integer, Ctg As Integer, cap As Integer
Dim deb As Double, cre As Double
Dim capitoli As Variant, capito As String
Set fgDa = Worksheets("Libro giornale")
Set fgA = Worksheets("Libro mastro")
capitoli = Array("uno", "due", "tre", "quattro", "cinque")
Ur = fgDa.Cells(65536, 2).End(xlUp).Row
For r = 7 To Ur
For c = 0 To 4
cap = fgA.Range(capitoli(c)).Value 'perché dentro alla cella che si chiama "uno" c'è scritto "1"
capito = capitoli(c)
If fgDa.Cells(r, 2).Value = cap Then
deb = fgDa.Cells(r, 5).Value
cre = fgDa.Cells(r, 6).Value
Call MandaInMastro(fgA, capito, deb, cre)
fgDa.Cells(r, 2).Value = "-" & cap
End If
Next c
Next r
End Sub
Sub MandaInMastro(fgA As Worksheet, capito As String, deb As Double, cre As Double)
fgA.Select
fgA.Range(capito).End(xlDown).Offset(1, 0).Select
ActiveCell.Value = deb
ActiveCell.Offset(0, 1).Value = cre
End Sub
|
