Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default FINDING LAST CELL IN A CALCUALTION

I am trying to average a series of numbers of a second sheet within
the same workbook. My equation is:
xlApp.Range("K7").Formula = "=AVERAGE('Earned Value'! H2,H500)"

I would like to use something similar to the following to ensure I get
the last cell.

xlApp.Range("K7").Formula = "=AVERAGE('Earned Value'! H2,H &
xlApp.ActiveSheet.Cells(xlApp.Rows.Count, ""k"").End(xlUp).Row"

Where have I gone wrong?

THanks
JEff
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default FINDING LAST CELL IN A CALCUALTION

Jeff

The thoery is good, I just think the syntax is a little off. This uses a
variable for ease of reading.

Dim lLastRow as Long

'Assume you want H here and not K, so I used 8
With xlApp.Sheets("Earned Value")
lLastRow = .Cells(.Rows.Count, 8).End(xlUp).Row
End With

xlApp.ActiveSheet.Range("K7").Formula = "=AVERAGE('Earned Value'! H2:H" &
lLastRow & ")"

If you are automating Excel from another application, you may have a problem
with the built-in constant xlUp (literal value = -4162).

--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com

Jeff wrote:
I am trying to average a series of numbers of a second sheet within
the same workbook. My equation is:
xlApp.Range("K7").Formula = "=AVERAGE('Earned Value'! H2,H500)"

I would like to use something similar to the following to ensure I get
the last cell.

xlApp.Range("K7").Formula = "=AVERAGE('Earned Value'! H2,H &
xlApp.ActiveSheet.Cells(xlApp.Rows.Count, ""k"").End(xlUp).Row"

Where have I gone wrong?

THanks
JEff



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
date calcualtion whitewater Excel Worksheet Functions 5 March 16th 07 03:59 PM
Calcualtion of renewal Latha Excel Worksheet Functions 1 September 16th 06 10:15 AM
Calcualtion of renewal Latha Excel Worksheet Functions 0 September 15th 06 09:11 PM
Calcualtion of renewal Latha Excel Worksheet Functions 0 September 15th 06 09:11 PM
Last cell In calcualtion problem Buster Excel Worksheet Functions 3 December 9th 04 06:27 PM


All times are GMT +1. The time now is 10:05 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"