Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default formula does not work in macro

Can some please please edit this macro for me? Possibly
TOM because
he has been extremely helpful. He gave me most of this
formula and i edited it to
add more formula and now it does not work. I have
recorded the
added formula but the recording formula refers to a
specific cell
; where as, i will like for it to find a designated cell
and
sum the totals. example: find vacation1 and sum all
vacation after
Comparing two other cells. I will be grateful with any
assistant.
this is the macro: I have also added notes in the macro

Sub supervisor()
Dim rng As Range
Set rng = Cells.Find("esn-personal1")
If Not rng Is Nothing Then
'the formula below does not work in this macro but works
well on the excel sheet
'it should find esn-personal1 and add this formula
rng.Offset(0, 1).Formula = "=SUMIF(c1:c101,"esn-
personal",e1:e101)"
rng.Offset(0, 1).BorderAround Weight:=xlMedium
End If
Set rng = Cells.Find("E-Time1")
If Not rng Is Nothing Then
'the formula below does not work in this macro but works
well on the excel sheet
'it should find esn-personal1 and add this formula
rng.Offset(0, 1).Formula = "==SUMIF
(c1:c101,"vacation",e1:e101)"
rng.Offset(0, 1).BorderAround Weight:=xlMedium
End If
Set rng = Cells.Find("sick1")
If Not rng Is Nothing Then
'the formula below does not work in this macro but works
well on the excel sheet
'it should find esn-personal1 and add this formula
rng.Offset(0, 1).Formula = "=SUMIF
(c1:c101,"vacation",e1:e101)"
rng.Offset(0, 1).BorderAround Weight:=xlMedium
End If
Set rng = Cells.Find("vacation1")
If Not rng Is Nothing Then
'the formula below does not work in this macro but works
well on the excel sheet
'it should find esn-personal1 and add this formula
rng.Offset(0, 1).Formula = "=SUMIF
(c1:c101,"vacation",e1:e101)"
rng.Offset(0, 1).BorderAround Weight:=xlMedium
End If
Set rng = Cells.Find("Lunch1")
If Not rng Is Nothing Then
'the formula below does not work in this macro but works
well on the excel sheet
'it should find esn-personal1 and add this formula
rng.Offset(0, 1).Formula = "=SUMIF
(c1:c101,"vacation",e1:e101)"
rng.Offset(0, 1).BorderAround Weight:=xlMedium
End If
'the formula below should find total1 subtract "lunch"
from "total")
Set rng = Cells.Find("total1")
If Not rng Is Nothing Then
rng.Offset(0, 1).FormulaR1C1 = "=R[-2]C-R[-1]C"
rng.Offset(0, 1).BorderAround Weight:=xlMedium
End If
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default formula does not work in macro

rng.Offset(0, 1).Formula = _
"=SUMIF(c1:c101,""esn-personal"",e1:e101)"

make a similar correction to all you formulas

quotes used within quotes need to be doubled.

--
Regards,
Tom Ogilvy


mary wrote in message
...
Can some please please edit this macro for me? Possibly
TOM because
he has been extremely helpful. He gave me most of this
formula and i edited it to
add more formula and now it does not work. I have
recorded the
added formula but the recording formula refers to a
specific cell
; where as, i will like for it to find a designated cell
and
sum the totals. example: find vacation1 and sum all
vacation after
Comparing two other cells. I will be grateful with any
assistant.
this is the macro: I have also added notes in the macro

Sub supervisor()
Dim rng As Range
Set rng = Cells.Find("esn-personal1")
If Not rng Is Nothing Then
'the formula below does not work in this macro but works
well on the excel sheet
'it should find esn-personal1 and add this formula
rng.Offset(0, 1).Formula = "=SUMIF(c1:c101,"esn-
personal",e1:e101)"
rng.Offset(0, 1).BorderAround Weight:=xlMedium
End If
Set rng = Cells.Find("E-Time1")
If Not rng Is Nothing Then
'the formula below does not work in this macro but works
well on the excel sheet
'it should find esn-personal1 and add this formula
rng.Offset(0, 1).Formula = "==SUMIF
(c1:c101,"vacation",e1:e101)"
rng.Offset(0, 1).BorderAround Weight:=xlMedium
End If
Set rng = Cells.Find("sick1")
If Not rng Is Nothing Then
'the formula below does not work in this macro but works
well on the excel sheet
'it should find esn-personal1 and add this formula
rng.Offset(0, 1).Formula = "=SUMIF
(c1:c101,"vacation",e1:e101)"
rng.Offset(0, 1).BorderAround Weight:=xlMedium
End If
Set rng = Cells.Find("vacation1")
If Not rng Is Nothing Then
'the formula below does not work in this macro but works
well on the excel sheet
'it should find esn-personal1 and add this formula
rng.Offset(0, 1).Formula = "=SUMIF
(c1:c101,"vacation",e1:e101)"
rng.Offset(0, 1).BorderAround Weight:=xlMedium
End If
Set rng = Cells.Find("Lunch1")
If Not rng Is Nothing Then
'the formula below does not work in this macro but works
well on the excel sheet
'it should find esn-personal1 and add this formula
rng.Offset(0, 1).Formula = "=SUMIF
(c1:c101,"vacation",e1:e101)"
rng.Offset(0, 1).BorderAround Weight:=xlMedium
End If
'the formula below should find total1 subtract "lunch"
from "total")
Set rng = Cells.Find("total1")
If Not rng Is Nothing Then
rng.Offset(0, 1).FormulaR1C1 = "=R[-2]C-R[-1]C"
rng.Offset(0, 1).BorderAround Weight:=xlMedium
End If
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to update a column in a work based on another work sheet WickerMan New Users to Excel 1 December 4th 09 12:58 PM
formula to work in a 3-d reference with 2 work books capt c Excel Worksheet Functions 1 April 8th 09 08:04 PM
A search for $ in a formula use to work now it does not work JuneJuly Excel Discussion (Misc queries) 2 November 30th 05 10:13 PM
Can a macro be made to work based on a formula? lonnied Excel Discussion (Misc queries) 2 January 26th 05 04:00 AM
Can a macro be made to work based on a formula? lonnied Excel Discussion (Misc queries) 0 January 26th 05 02:59 AM


All times are GMT +1. The time now is 01:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"