Myst3ryssss
New Member
- Joined
- Jul 28, 2011
- Messages
- 3
Hi,(I will try in english).
I have a Excel document with two sheets inside.
I have a input form (Sheet "Ajouter"):
This form input my entrys in this little database (Sheet "Mouvement")
My input Macro is:
Okay, the problem is the next one:
If I put 0$ in the "Valeur Marchande" field and then I press "Insérer", the entry will get input like this:
As you can see, it make unbalance the "profit/perte" colum. So, I want to know if it's possible to add something in the input macro that make it check if the "valeur marchande" field is = 0$:
- IF no, the entry is add normally
- IF yes, the macro go get the last most recent value of "Valeur Marchande" in the "Mouvement" sheet, for the good account (compte).
Exemple:
I select the account "CELI", then I put 0$ in the "Valeur marchande" field and then, I press "insérer".
The macro detect that "valeur Marchande" = 0. It go take the most recent value for the "CELI" account in my "mouvement" Sheet and replace the 0$ by this price.
I have already make a little formula (not in VBA) to try to see how I can get this "most recent value", and i got this:
RECHERCHE_PLAGE_VAL0
This is work 50/50. If I put 0$ in C10 it's ok and the formula show the good amount. If I put 1$ then it return me "FAUX".
So I have 3 question:
Maxime
P.s. Don't worry, you can post your formula in english, I'll make the translation myself.
I have a Excel document with two sheets inside.
I have a input form (Sheet "Ajouter"):
This form input my entrys in this little database (Sheet "Mouvement")
My input Macro is:
Code:
Sub nouvelle_valeur()
'
' nouvelle_valeur Macro
'
'
Sheets("Mouvement").Select
Rows("2:2").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Sheets("Ajouter").Select
Range("A2:D2").Select
Selection.Copy
Sheets("Mouvement").Select
Range("A2:D2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("E2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=RC[-1]-RC[-2]"
Range("E3").Select
Sheets("Ajouter").Select
Range("C10").Select
Selection.ClearContents
Range("C7").Select
Selection.ClearContents
ActiveWorkbook.RefreshAll
End Sub
Okay, the problem is the next one:
If I put 0$ in the "Valeur Marchande" field and then I press "Insérer", the entry will get input like this:
As you can see, it make unbalance the "profit/perte" colum. So, I want to know if it's possible to add something in the input macro that make it check if the "valeur marchande" field is = 0$:
- IF no, the entry is add normally
- IF yes, the macro go get the last most recent value of "Valeur Marchande" in the "Mouvement" sheet, for the good account (compte).
Exemple:
I select the account "CELI", then I put 0$ in the "Valeur marchande" field and then, I press "insérer".
The macro detect that "valeur Marchande" = 0. It go take the most recent value for the "CELI" account in my "mouvement" Sheet and replace the 0$ by this price.
I have already make a little formula (not in VBA) to try to see how I can get this "most recent value", and i got this:
Code:
=SI(Ajouter!C10=0;RECHERCHEV(B2;Mouvement!RECHERCHE_PLAGE_VAL0;3;FAUX))
RECHERCHE_PLAGE_VAL0
Code:
=DECALER(Mouvement!$A$1;1;1;NBVAL(Mouvement!$A$1:$A$20)-1;4)
This is work 50/50. If I put 0$ in C10 it's ok and the formula show the good amount. If I put 1$ then it return me "FAUX".
So I have 3 question:
- How can I change this "FAUX" return...for "do nothing"?
- How can I "transform" this RECHERCHEV formula to make it fit in my macro?
- How can I "create" a fonction that will replace the 0$ value by the RECHERCHEV return value?
Maxime
P.s. Don't worry, you can post your formula in english, I'll make the translation myself.