
21-03-11, 15:08
|
| Όνομα: Θανάσης Έκδοση λογισμικού Office: Ms-Office 2013 Γλώσσα λογισμικού Office: Αγγλική | | Εγγραφή: 13-02-2010
Μηνύματα: 62
| |
Αγαπητέ Τάσο σε ευχαριστώ για την βοήθεια σου αλλά το πρόβλημα παραμένει.
Θα σε παρακαλούσα εάν μπορείς να με βοηθήσεις για να το ξεπεράσω.
Φιλικά
Θανάσης Κώδικας: Option Explicit
Sub Offer()
Dim FirstRow As Long, FinalRow As Long
FirstRow = ActiveCell.Row
FinalRow = Cells(Rows.Count, 2).End(xlUp).Row
If FirstRow < 2 Or FirstRow >= FinalRow Then
'Can not be a valid Range... Show some message...
End If
Application.ScreenUpdating = False
' Cost Net
With Range("K" & FirstRow & ":K" & FinalRow)
.Formula = "=IF(J3<>"""",ROUND(J3*(1-Supplier%),2),"""")"
Από αυτό το σημείο δημιουργείτε πρόβλημα διότι οι πράξεις πρέπει να γίνονται από το σημείο
που είναι ο κέρσορας και κάτω και όχι από την αρχή (J3, K3, etc).
.Value = .Value 'Convert Formulas to Values
End With
' Unit Price
With Range("I" & FirstRow & ":I" & FinalRow)
.Formula = "=IFERROR(ROUND(K3*(1+Owners%),2), """")"
.Value = .Value
End With
With Range("I" & FirstRow & ":I" & FinalRow)
.Formula = "=IF(H3<>"""",ROUND(K3*(1+(Owners%)),2),"""")"
.Value = .Value
End With
' Total Cost
With Range("L" & FirstRow & ":L" & FinalRow)
.Formula = "=IF(K3<>"""",H3*K3,"""")"
.Value = .Value
End With
' Total Sales
With Range("M" & FirstRow & ":M" & FinalRow)
.Formula = "=IF(I3<>"""",H3*I3,"""")"
.Value = .Value
End With
' Enter the Total Row
Range("K3").Copy
With Range("K" & FinalRow + 1).Resize(4, 3)
.PasteSpecial xlPasteFormats
Application.CutCopyMode = False
.Font.Bold = True
.Font.Italic = True
With .Resize(1, 3)
.Item(1).Value = "Total"
.Item(2).Formula = "=SUM(L3:L" & FinalRow & ")"
.Item(3).Formula = "=SUM(M3:M" & FinalRow & ")"
.Font.ColorIndex = xlAutomatic
With .Offset(1).Resize(3, 3)
.Item(1).Value = "Profit"
.Item(3).Formula = "=SUM(M3:M" & FinalRow & ")- SUM(L3:L" & FinalRow & ")"
.Item(4).Value = "P/C"
.Item(6).Formula = "=(SUM(M3:M" & FinalRow & ")- SUM(L3:L" & FinalRow & "))/(SUM(L3:L" & FinalRow & "))"
.Item(6).NumberFormat = "0.00%"
.Item(7).Value = "P/S"
.Item(9).Formula = "=(SUM(M3:M" & FinalRow & ")- SUM(L3:L" & FinalRow & "))/(SUM(M3:M" & FinalRow & "))"
.Item(9).NumberFormat = "0.00%"
.Font.ColorIndex = 41&
End With
'.Value = .Value 'Convert Formulas to Values
End With
End With
Application.ScreenUpdating = True
End Sub
|