Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Please help. I am trying to get the last row of every shee to use in a sumproduct formula. I am using the below code. For some reason it only works on some of the sheets. Thx Sub shname() Dim wks As Worksheet Dim shlast As Long Dim r As Range For Each wks In ThisWorkbook.Worksheets shlast = lastrow(wks) Set r = wks.Range("N1") r.Value = shlast Next wks Application.ScreenUpdating = True End Sub Function lastrow(sh As Worksheet) ('found on the web) On Error Resume Next lastrow = sh.Cells.Find(What:="*", _ After:=sh.Range("A1"), _ Lookat:=xlPart, _ LookIn:=xlFormulas, _ SearchOrder:=xlByRows, _ SearchDirection:=xlPrevious, _ MatchCase:=False).Row On Error GoTo 0 End Function |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Finding Info from sheet 1 and removing only those rows from sheet | Excel Discussion (Misc queries) | |||
Finding data of one sheet in another sheet | Excel Programming | |||
Better way of finding last row on sheet | Excel Programming | |||
finding a value thats present more than once in a sheet | Excel Programming | |||
Finding last sheet | Excel Programming |