Simon,
Thanks for your suggestion, but this does not go either, i get a 'Run-time
error 1004' 'Application-defined or object-defined error'. But as soon as i
put an character in front of the string (variant or sting type stgText) it
runs, just putting text in the comumn.
I have no clue what goes wrong because with the following code i have no
trouble;
.Cells(Val(stgMaxRow) - 3, 6) = "=sum(F2:F" & Trim(Str(Val(stgMaxRow) -
5)) & ")"
It perfectly puts the folmula in the desination cell.
Hopefully someone knows the answer here.
Cheers,
Ludovic
"Simon Lloyd" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
>
> Try this:
>
> Code:
> --------------------
> Dim intT As Integer, stgText As Variant
> With objActiveWorkSheet
> For intT = 2 To (stgMaxRow - 5)
> stgText = "=IF(F" & Trim(Str(intT)) & ">1000;" & Chr(34) & "X" & Chr(34)
> & ";" & Chr(34) & "" & Chr(34) & ")"
> .Cells(intT, 11).Formula = stgText
> Next
> End With
> --------------------
>
>
> Vsn;551952 Wrote:
>> Hi all,
>>
>> Who could give me a clue on what I do wrong, I realy can't get it right
>> here.
>>
>> I export data from Access to Excel, so far all fine. Than I format the
>> excel
>> sheet a bit etc. als ok. But now I would like to write a formula to a
>> group
>> of cells, and this does not work and i can't figure out what goes
>> wrong, the
>> cells just apear blank.
>>
>> >
> Code:
> --------------------
> > >
> > Dim intT As Integer, stgText As String
> > With objActiveWorkSheet
> > For intT = 2 To (stgMaxRow - 5)
> > stgText = "=IF(F" & Trim(Str(intT)) & ">1000;" & Chr(34) & "X" &
> > Chr(34) & ";" & Chr(34) & "" & Chr(34) & ")"
> > 'stgText = "-" & stgText
> > .Cells(intT, 11) = stgText
> > Next
> > End With
> >
> --------------------
>> >
>> If I put any character in front of the string stgText it just prints
>> the
>> text without trouble. Just to get the Excel formula to work seems a
>> problem.
>> And strange enough I manage to to it elsewere in the sheet with
>> >
> Code:
> --------------------
> > >
> > ..Cells(Val(stgMaxRow) - 3, 6) = "=sum(F2:F" &
> Trim(Str(Val(stgMaxRow) - 5))
> > & ")"
> >
> --------------------
>> >
>> Suggestions are highly appriciated.
>>
>> Cheers,
>> Ludovic
>
>
> --
> Simon Lloyd
>
> Regards,
> Simon Lloyd
> 'Microsoft Office Help' (http://www.thecodecage.com)
> ------------------------------------------------------------------------
> Simon Lloyd's Profile:
> http://www.thecodecage.com/forumz/member.php?userid=1
> View this thread:
> http://www.thecodecage.com/forumz/sh...d.php?t=152093
>
> Microsoft Office Help
>