Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi, How come this works: Set sourceRange = mybook.Worksheets(1).Range("A2:IV" & lrow) but this doesn't: Set sourceRange = mybook.Worksheets(1).Range(Cells(1, 1), Cells(lrow, lcol))) I get object defined error. here are the functions I'm using: Function LastRow(sh As Worksheet) ' Find the last real row 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 Function LastCol(sh As Worksheet) ' Find the last real column On Error Resume Next LastCol = sh.Cells.Find(What:="*", _ After:=sh.Range("A1"), _ Lookat:=xlPart, _ LookIn:=xlFormulas, _ SearchOrder:=xlByColumns, _ SearchDirection:=xlPrevious, _ MatchCase:=False).Column On Error GoTo 0 End Function lrow and lcol both dimmed as long in my sub. Thank you much. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Subscript out of range error - save copy error | Excel Programming | |||
Subscript out of range error - save copy error | Excel Programming | |||
Range.Select error and screen maximizing error in Workbook_Open() | Excel Programming | |||
Range.Select error and screen maximizing error in Workbook_Open() | Excel Programming | |||
Type Mismatch error & subscript out of range error | Excel Programming |