LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Run-time error 1004 on variable

Dim rng as Range
set rng = Wrks1.Range("LaborDBDW")
for i = rng.row to Entries + 25


if you put row on a multicell range, it returns the row of the first cell in
the range

if you want the last row

msgbox rng.rows(rng.rows.count).Row

I just set rng to Wrks1.Range("LaborDBDW") to save typing. You can use it
directly.

If you really want to loop through that range

for each cell in Wrks1.Range("LaborDBDW")
msgbox cell.Value & " - " & cell.Address(0,0) & " - " & cell.row
Next

as an example.

--
regards,
Tom Ogilvy



"Casey" wrote in
message ...

Tom & Jim,
Exactly the solution. I'm just staring to get the hang of looping with
variables and I make elementry mistakes constantly. Your prescription
cured my OP but revealed another problem with the routine. If I could
ask a follow up question?

The line I use to define Entries;
Entries = Excel.WorksheetFunction.CountA(Wrks1.Range("LaborD BDW"))
contains a name range ("LaborDBDW") that gets moved up and down because
of Rows being inserted and deleted above it on the worksheet (might be
Rows 15-35 one time and Rows 14-34 the next time). However, when the
macro runs it picks up at Row 6 which is definately outside
("LaborDBDW"). Could I name the row at the top of ("LaborDBDW") and
use that in the For i = 1 To Entries + 25 somehow so it stars reading
info in the correct place?


--
Casey


------------------------------------------------------------------------
Casey's Profile:

http://www.excelforum.com/member.php...fo&userid=4545
View this thread: http://www.excelforum.com/showthread...hreadid=537003





 
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
Run time error 1004, General ODBC error [email protected] New Users to Excel 0 September 19th 05 01:41 AM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Run time error 1004 General ODCB Error Kevin Excel Programming 3 February 26th 05 12:51 PM
Application Run Time Error 1004 and Stack Error ExcelMonkey[_190_] Excel Programming 9 February 11th 05 04:48 PM
Simple For-Loop gives 1004 error using variable to EntireRow.Delete EdMX Excel Programming 3 December 2nd 04 02:43 AM


All times are GMT +1. The time now is 11:49 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"