Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello all,
I am trying to use the following code (courtesy of Tom Ogilvy) to colour the range from B26 to the last occupied cell without success. You will note that I have named the last occupied cell 'Lastcell' thinking this will help with selection and delete it at the end as I need to use it with different sheets in the same workbook. Where am I going wrong? Sub GetRealLastCell() Dim RealLastRow As Long Dim RealLastColumn As Long Range("A1").Select On Error Resume Next RealLastRow = _ Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row RealLastColumn = _ Cells.Find("*", [A1], , , xlByColumns, xlPrevious).Column Cells(RealLastRow, RealLastColumn).Select ActiveWorkbook.Names.Add Name:="LastCell" Range("b26:LastCell").Select With Selection.Interior .ColorIndex = 6 .Pattern = xlSolid End With ActiveWorkbook.Names("lastcell").Delete End Sub TIA |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Selecting range in list of range names depending on a cell informa | Excel Discussion (Misc queries) | |||
Selecting A Range | Excel Programming | |||
Selecting A Range | Excel Programming | |||
Selecting A Range | Excel Programming | |||
selecting a range | Excel Programming |