Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Excel XP, Win Vista
I have a table of formulas that produce blank cells on condition. To set the print range I want to find the first non-blank cell in Column A looking from the bottom up. Doing End(xlUp) will hit on the first formula cell (looking up) and not the first non-blank cell. Looping up through Column A looking for a value of not zero will find what I want. Question: Is there a better way? Thanks for your time. Otto |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dim rng As Range
Set rng = Range("C" & Rows.Count).End(xlUp) Set rng = rng.End(xlUp) -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Otto Moehrbach" wrote in message ... Excel XP, Win Vista I have a table of formulas that produce blank cells on condition. To set the print range I want to find the first non-blank cell in Column A looking from the bottom up. Doing End(xlUp) will hit on the first formula cell (looking up) and not the first non-blank cell. Looping up through Column A looking for a value of not zero will find what I want. Question: Is there a better way? Thanks for your time. Otto |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Slight correctrion
Dim rng As Range Set rng = Range("C" & Rows.Count).End(xlUp) Do Until rng.Value < "" Set rng = rng.End(xlUp) Loop -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Otto Moehrbach" wrote in message ... Excel XP, Win Vista I have a table of formulas that produce blank cells on condition. To set the print range I want to find the first non-blank cell in Column A looking from the bottom up. Doing End(xlUp) will hit on the first formula cell (looking up) and not the first non-blank cell. Looping up through Column A looking for a value of not zero will find what I want. Question: Is there a better way? Thanks for your time. Otto |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here is some code that leverages find...
Sub test2() MsgBox LastCell(rng:=Sheet1.Range("B:B")).Address End Sub Public Function LastCell(Optional ByVal wks As Worksheet, Optional rng As Range) As Range Dim lngLastRow As Long Dim lngLastColumn As Long If wks Is Nothing Then Set wks = ActiveSheet If rng Is Nothing Then rng = wks.Cells On Error Resume Next lngLastRow = rng.Find(What:="*", _ After:=rng(1), _ Lookat:=xlPart, _ LookIn:=xlValues, _ SearchOrder:=xlByRows, _ SearchDirection:=xlPrevious, _ MatchCase:=False).Row lngLastColumn = rng.Find(What:="*", _ After:=rng(1), _ Lookat:=xlPart, _ LookIn:=xlValues, _ SearchOrder:=xlByColumns, _ SearchDirection:=xlPrevious, _ MatchCase:=False).Column On Error GoTo 0 If lngLastRow = 0 Then lngLastRow = 1 lngLastColumn = 1 End If Set LastCell = wks.Cells(lngLastRow, lngLastColumn) End Function -- HTH... Jim Thomlinson "Otto Moehrbach" wrote: Excel XP, Win Vista I have a table of formulas that produce blank cells on condition. To set the print range I want to find the first non-blank cell in Column A looking from the bottom up. Doing End(xlUp) will hit on the first formula cell (looking up) and not the first non-blank cell. Looping up through Column A looking for a value of not zero will find what I want. Question: Is there a better way? Thanks for your time. Otto |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bob, Jim
Thanks for the help. Otto "Otto Moehrbach" wrote in message ... Excel XP, Win Vista I have a table of formulas that produce blank cells on condition. To set the print range I want to find the first non-blank cell in Column A looking from the bottom up. Doing End(xlUp) will hit on the first formula cell (looking up) and not the first non-blank cell. Looping up through Column A looking for a value of not zero will find what I want. Question: Is there a better way? Thanks for your time. Otto |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Start Cell B1 then find first blank cell, insert subtotal, next non blank, then next blank, sutotal cells in between......... | Excel Programming | |||
Find First Non blank cell than find column header and return that value | Excel Worksheet Functions | |||
Find first blank cell | Excel Programming | |||
find next blank cell | Excel Programming | |||
Find and blank cell then Do this..... | Excel Programming |