Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I'm trying to put a formula into a cel, using the code below (which I also found on a newsgroup). The formula gets into the cel the right way, but the value displayed is an errormessage "#NAME". However. When I manually select the cell, press F2 and Enter. The value is displayed correctly. Can anyone tell me how I put this into my code? Many Thanks, Rinze Smit, Revalidatie Friesland Sub Formuleplaatsen() ' Go to first cell of column Range("D2").Select ' Test for entry in row2, if blank, use End Down to go to first non-blank cell If ActiveCell.Value = "" Then Selection.End(xlDown).Select ' Capture address of first cell of range StartA = ActiveCell.Address(rowabsolute:=False, columnabsolute:=False) ' Go to bottom of range Selection.End(xlDown).Select ' Capture address of end of range EndA = ActiveCell.Address(rowabsolute:=False, columnabsolute:=False) ' Move to cell to enter formula ActiveCell.Offset(2, 0).Select ' Define formula Totaal = "=Som(" & StartA & " : " & EndA & ")" ' Enter formula into worksheet ActiveCell.Formula = Totaal End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Use English function name for the Formula property
Totaal = "=Som(" & StartA & " : " & EndA & ")" should be Totaal = "=SUM(" & StartA & " : " & EndA & ")" -- Regards, Tom Ogilvy "Rinze Smit" wrote in message l.com... Hi, I'm trying to put a formula into a cel, using the code below (which I also found on a newsgroup). The formula gets into the cel the right way, but the value displayed is an errormessage "#NAME". However. When I manually select the cell, press F2 and Enter. The value is displayed correctly. Can anyone tell me how I put this into my code? Many Thanks, Rinze Smit, Revalidatie Friesland Sub Formuleplaatsen() ' Go to first cell of column Range("D2").Select ' Test for entry in row2, if blank, use End Down to go to first non-blank cell If ActiveCell.Value = "" Then Selection.End(xlDown).Select ' Capture address of first cell of range StartA = ActiveCell.Address(rowabsolute:=False, columnabsolute:=False) ' Go to bottom of range Selection.End(xlDown).Select ' Capture address of end of range EndA = ActiveCell.Address(rowabsolute:=False, columnabsolute:=False) ' Move to cell to enter formula ActiveCell.Offset(2, 0).Select ' Define formula Totaal = "=Som(" & StartA & " : " & EndA & ")" ' Enter formula into worksheet ActiveCell.Formula = Totaal End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Tom,
I thought I'd already tried that..... But NO. My memory had 'left' me. Worked out fine. Thanks a lot. Rinze "Tom Ogilvy" wrote in message ... Use English function name for the Formula property Totaal = "=Som(" & StartA & " : " & EndA & ")" should be Totaal = "=SUM(" & StartA & " : " & EndA & ")" -- Regards, Tom Ogilvy "Rinze Smit" wrote in message l.com... Hi, I'm trying to put a formula into a cel, using the code below (which I also found on a newsgroup). The formula gets into the cel the right way, but the value displayed is an errormessage "#NAME". However. When I manually select the cell, press F2 and Enter. The value is displayed correctly. Can anyone tell me how I put this into my code? Many Thanks, Rinze Smit, Revalidatie Friesland Sub Formuleplaatsen() ' Go to first cell of column Range("D2").Select ' Test for entry in row2, if blank, use End Down to go to first non-blank cell If ActiveCell.Value = "" Then Selection.End(xlDown).Select ' Capture address of first cell of range StartA = ActiveCell.Address(rowabsolute:=False, columnabsolute:=False) ' Go to bottom of range Selection.End(xlDown).Select ' Capture address of end of range EndA = ActiveCell.Address(rowabsolute:=False, columnabsolute:=False) ' Move to cell to enter formula ActiveCell.Offset(2, 0).Select ' Define formula Totaal = "=Som(" & StartA & " : " & EndA & ")" ' Enter formula into worksheet ActiveCell.Formula = Totaal End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
avoid Descending Sort putting error cells uppermost in collumn | Excel Worksheet Functions | |||
putting a name in a formula | Excel Discussion (Misc queries) | |||
Putting line between formula | Excel Discussion (Misc queries) | |||
putting 2 conditions in a formula | Excel Discussion (Misc queries) | |||
Excel keeps putting .xls] on my sheets and then I get an error | Excel Discussion (Misc queries) |