Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default Help in creating formula in a macro

The following code is working, now I need to use the value in line 6
and divided into line 7...how to do

1. With ActiveSheet
2. lfR = 1
3. For lcR = 1 To .Cells(.Rows.Count, "B").End(xlUp).Row + 1
4. If Len(Trim(.Cells(lcR, 1))) = 0 Then
5. .Cells(lcR, 2) = .Cells(lcR - 1, 2) '& "- Averages"
6. .Cells(lcR, 8).Formula = "=SUM(H" & lfR & ":H" & lcR - 1 &
")"
7. .Cells(lcR, 9).Formula = "=SUM(I" & lfR & ":I" & lcR - 1 &
")"
------ .Cells(lcR, 7).Formula = <-------need help here, the sum of
H divided into the sum of I.
8. lfR = lcR + 1
9. End If
10. Next
11. End With
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Help in creating formula in a macro

Wouldn't you just want the two cell addresses divided out?

..Cells(lcR, 7).Formula = "=" & .Cells(lcR, 8).Address(0, 0) / _
.Cells(lcR, 8).Address(0, 0)

The (0, 0) arguments for the Address property just means to use a relative
row and column reference.

--
Rick (MVP - Excel)


"S Himmelrich" wrote in message
...
The following code is working, now I need to use the value in line 6
and divided into line 7...how to do

1. With ActiveSheet
2. lfR = 1
3. For lcR = 1 To .Cells(.Rows.Count, "B").End(xlUp).Row + 1
4. If Len(Trim(.Cells(lcR, 1))) = 0 Then
5. .Cells(lcR, 2) = .Cells(lcR - 1, 2) '& "- Averages"
6. .Cells(lcR, 8).Formula = "=SUM(H" & lfR & ":H" & lcR - 1 &
")"
7. .Cells(lcR, 9).Formula = "=SUM(I" & lfR & ":I" & lcR - 1 &
")"
------ .Cells(lcR, 7).Formula = <-------need help here, the sum of
H divided into the sum of I.
8. lfR = lcR + 1
9. End If
10. Next
11. End With


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Help in creating formula in a macro

x = .Cells*lcR, 9).Value/.Cells(lcR, 8).Value




"S Himmelrich" wrote in message
...
The following code is working, now I need to use the value in line 6
and divided into line 7...how to do

1. With ActiveSheet
2. lfR = 1
3. For lcR = 1 To .Cells(.Rows.Count, "B").End(xlUp).Row + 1
4. If Len(Trim(.Cells(lcR, 1))) = 0 Then
5. .Cells(lcR, 2) = .Cells(lcR - 1, 2) '& "- Averages"
6. .Cells(lcR, 8).Formula = "=SUM(H" & lfR & ":H" & lcR - 1 &
")"
7. .Cells(lcR, 9).Formula = "=SUM(I" & lfR & ":I" & lcR - 1 &
")"
------ .Cells(lcR, 7).Formula = <-------need help here, the sum of
H divided into the sum of I.
8. lfR = lcR + 1
9. End If
10. Next
11. End With



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
Creating formula or macro Vecah Excel Worksheet Functions 0 November 5th 08 03:19 PM
Creating a formula in Macro Govind[_2_] Excel Programming 2 September 9th 08 05:01 PM
Creating Macro/Formula Diana Excel Programming 2 February 20th 07 06:14 PM
Help creating Formula (or macro) bman342 Excel Discussion (Misc queries) 3 April 9th 06 06:13 PM
Help creating a Macro or Formula [email protected] Excel Programming 1 August 12th 04 03:16 AM


All times are GMT +1. The time now is 07:41 AM.

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"