LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default Inconsistent error select range?! Driving me crazy.

I have programmed many routines in which I need to dynamically select a range.

However, lately, I am getting an error message when selection a range.

Sub myCode()

dim lRow as long
dim lCol as long
dim wks as worksheet
dim wb as workbook
dim myRng as range


set wb = thisworkbook
set wks = wb.sheets("recordset")
lRow = wks.range("a1").end(xlDown).row
lCol = wks.range("a1").end(xlToRight).column

set myRng = wks.range(cells(1,1), cells(lRow, lCol))

Sometimes the above statement is causing a error

"Run time error '1004'"

Method 'Range' of object '_Worksheet' failed

I am using Excel XP.

Can anybody makes sense of this and why I get this error sometimes?

Thanks.
 
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
Driving me CRAZY~ please help Tara New Users to Excel 0 July 7th 08 07:29 PM
Worksheets(i).Select - driving me crazy! Geoff C Excel Programming 5 August 7th 07 02:34 PM
Error Driving Me Crazy internacio[_10_] Excel Programming 3 March 15th 06 07:03 PM
Error Handling driving me crazy. Please help hyyfte[_17_] Excel Programming 2 September 22nd 04 07:06 PM
Driving me crazy! Dick Kusleika[_3_] Excel Programming 0 October 21st 03 10:18 PM


All times are GMT +1. The time now is 11:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"