Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Using result of function as row number

Dim LastRow As Long
If WorksheetFunction.CountA(Cells) 0 Then

'Search for any entry, by searching backwards by Rows.
LastRow = Cells.Find(What:="*", After:=[A1], _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

End If

Range("A" & LastRow + 2).Formula = "=SUM(A1:A" & LastRow & ")"


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"nospaminlich" wrote in message
...
I need to add a Count of non blank cells between Row 2 and the last row of
(non contiguous) data on a worksheet 2 rows below the last row.

Using the code from OzGrid:
Dim LastRow As Long
If WorksheetFunction.CountA(Cells) 0 Then

'Search for any entry, by searching backwards by Rows.
LastRow = Cells.Find(What:="*", After:=[A1], _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

End If

returns the last row number correctly

The next step is to use that to move to the relevant cell and add the
Count
formula e.g. something like

Range("R[LastRow+2]:C1").Select

should take me to Col A Row 45 where LastRow returns 43 so I can add the
formula

I've obviously got the syntax wrong here. There must be a way of using
the
result of LastRow to determine the cell address to select but I just can't
see it

I'd really appreciate some help with this

Thanks a lot



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
The number 28232 result when using NETWORKDAYS function seymourgomez Excel Worksheet Functions 1 March 18th 08 08:55 PM
True number as the result to an If-Then function kingham78 Excel Discussion (Misc queries) 2 October 12th 06 12:09 PM
True number as the result to an If-Then function kingham Excel Discussion (Misc queries) 2 October 11th 06 10:37 PM
True number as the result to an If-Then function kingham Excel Discussion (Misc queries) 0 October 11th 06 10:28 PM
True number as the result to an If-Then function kingham Excel Discussion (Misc queries) 0 October 11th 06 10:27 PM


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