function help

M

Mike VB

Hello
I've an error:

Sheets(SheetDestination).Cells(row, col).Formula =
"=(19981,1882918624*452)/19981,1882918624"

En fait ma ligne de code exact est:
Sheets(SheetDestination).Cells(row, col).Formula = _
"=(" & Sheets(SheetSource).Cells(row, col).Value & _
"*" & Base & ") / " & ValEnt


Regrads
 
T

Tom Ogilvy

Some added thoughts.

What error are you getting.

is row a number between 1 and 65536
is col a number between 1 and 256 or a single letter between a and z or a
double letter between AA and IV
Is SheetDestination a string variable having a value that corresponds to an
existing sheet name. Is that Sheet a worksheet?
 
M

Mike VB

Hi

this my source code

FeuilleSource = "feuil1"
FeuilleDestination = "feuil2"

firstCol = 2
lastCol = 4
ColonneNational = 5

firstrow = 2
DerniereLigne = 100

For colonne = firstCol To lastCol
ValEnt = ""
For ligne = firstrow To DerniereLigne
If Sheets(FeuilleSource).Cells(ligne, colonne).Value <> "" Then
If ValEnt = "" Then
ValEnt = Sheets(FeuilleSource).Cells(ligne, colonne).Value
ValeurNational = Sheets(FeuilleSource).Cells(ligne,
ColonneNational).Value
End If
Sheets(FeuilleDestination).Cells(ligne, colonne).Formula = _
"=(" & Sheets(FeuilleSource).Cells(ligne, colonne).Value & _
"*" & ValeurNational & ") / " & ValEnt
End If
Next ligne
Next colonne


Best regards,
Mike
 
N

NickHK

Mike,
Is there any point using .Formula when all your values are numbers not
refences ?

Also, doesn't your formaul boil down to:
[Destination].Formula = ValeurNational

Add a Debug.Print ValEnt, after ValEnt assignment to see what value you are
using.

It doesn't look like you are declaring your variable either.

NickHK
 
Top