PC Review


Reply
Thread Tools Rate Thread

I am always getting these errors and I never understand why.

 
 
Jonathan Brown
Guest
Posts: n/a
 
      19th Feb 2009
Here is some code that I'm working on. It's choking on the second loop
statement. I'm getting the Run-time error '1004': Application-defined or
object-defined error. I get this error message all the time and it's driving
me nuts. After some fiddling I'm able to work around it but I can't get past
it this time. Here's the code:

Dim DateValidation As Range
Dim SingleDate As Range
Dim ManningDate As Range
Dim BlankCounter As Integer

Set DateValidation = Application.InputBox(Prompt:="Please select the week(s)
to validate on the Yearly Manning sheet.", _
Title:="Select week(s) to validate", Default:=Selection.Address, Type:=8)
On Error GoTo 0

If DateValidation Is Nothing Then Exit Sub

For Each SingleDate In DateValidation
If Not IsDate(SingleDate) Then
MsgBox "Please select only the week ending dates that you wish
to validate", vbInformation, "Oops, wrong spot"
Exit Sub
End If
Next SingleDate

For Each SingleDate In Sheets("Yearly Manning").Range(DateValidation.Address)

BlankCounter = 0

For Each ManningDate In Sheets("Yearly
Manning").Range(SingleDate.EntireColumn)

If ManningDate.Value = "" Then
BlankCounter = BlankCounter + 1
Else
BlankCounter = 0
End If

If BlankCounter > 15 Then
Exit For
Else
'''Do more stuff here
End If

Next ManningDate

Next SingleDate

The error message is coming up on the second loop statement: For Each
ManningDate In Sheets("Yearly Manning").Range(SingleDate.EntireColumn)

What is wrong with using the entire column as my range? As you can I have a
BlankCounter to get out of the loop once I go through enough blank rows.
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      19th Feb 2009
Here is one way to write it so it will give you a good range reference:
For Each ManningDate In Sheets("Yearly Manning") _
..Range(SingleDate.Column & ":" & SingleDate.Column)


"Jonathan Brown" wrote:

> Here is some code that I'm working on. It's choking on the second loop
> statement. I'm getting the Run-time error '1004': Application-defined or
> object-defined error. I get this error message all the time and it's driving
> me nuts. After some fiddling I'm able to work around it but I can't get past
> it this time. Here's the code:
>
> Dim DateValidation As Range
> Dim SingleDate As Range
> Dim ManningDate As Range
> Dim BlankCounter As Integer
>
> Set DateValidation = Application.InputBox(Prompt:="Please select the week(s)
> to validate on the Yearly Manning sheet.", _
> Title:="Select week(s) to validate", Default:=Selection.Address, Type:=8)
> On Error GoTo 0
>
> If DateValidation Is Nothing Then Exit Sub
>
> For Each SingleDate In DateValidation
> If Not IsDate(SingleDate) Then
> MsgBox "Please select only the week ending dates that you wish
> to validate", vbInformation, "Oops, wrong spot"
> Exit Sub
> End If
> Next SingleDate
>
> For Each SingleDate In Sheets("Yearly Manning").Range(DateValidation.Address)
>
> BlankCounter = 0
>
> For Each ManningDate In Sheets("Yearly
> Manning").Range(SingleDate.EntireColumn)
>
> If ManningDate.Value = "" Then
> BlankCounter = BlankCounter + 1
> Else
> BlankCounter = 0
> End If
>
> If BlankCounter > 15 Then
> Exit For
> Else
> '''Do more stuff here
> End If
>
> Next ManningDate
>
> Next SingleDate
>
> The error message is coming up on the second loop statement: For Each
> ManningDate In Sheets("Yearly Manning").Range(SingleDate.EntireColumn)
>
> What is wrong with using the entire column as my range? As you can I have a
> BlankCounter to get out of the loop once I go through enough blank rows.

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      19th Feb 2009
You asked what is wrong with using EntireColumn as a range. In this case,
there are at least two things wrong. 1. The For Each statement will look
for something that is indexed like a series of cells in a range or a list or
an array. 2. The Range object class is not designed to use EntireRow or
EntireColumn as having the characteristics of an argument for that object
class. So, it tells you that in this case the Application cannot process
that code configuration. The Range object class can accept a single cell
address as a string argument like ("A1") or as series of cell addresses like
("A1:B15, C12, D2:E5") or rows like ("2:5") and columns like ("C:F"). But
EntireRow and EntireColumn alone do not return a string address for a cell
that the Range object class can recognize. But if you add the keyword
Address to them, they should work.

For Each ManningDate In Sheets("Yearly Manning") _
..Range(SingleDate.EntireColumn.Address)


"Jonathan Brown" wrote:

> Here is some code that I'm working on. It's choking on the second loop
> statement. I'm getting the Run-time error '1004': Application-defined or
> object-defined error. I get this error message all the time and it's driving
> me nuts. After some fiddling I'm able to work around it but I can't get past
> it this time. Here's the code:
>
> Dim DateValidation As Range
> Dim SingleDate As Range
> Dim ManningDate As Range
> Dim BlankCounter As Integer
>
> Set DateValidation = Application.InputBox(Prompt:="Please select the week(s)
> to validate on the Yearly Manning sheet.", _
> Title:="Select week(s) to validate", Default:=Selection.Address, Type:=8)
> On Error GoTo 0
>
> If DateValidation Is Nothing Then Exit Sub
>
> For Each SingleDate In DateValidation
> If Not IsDate(SingleDate) Then
> MsgBox "Please select only the week ending dates that you wish
> to validate", vbInformation, "Oops, wrong spot"
> Exit Sub
> End If
> Next SingleDate
>
> For Each SingleDate In Sheets("Yearly Manning").Range(DateValidation.Address)
>
> BlankCounter = 0
>
> For Each ManningDate In Sheets("Yearly
> Manning").Range(SingleDate.EntireColumn)
>
> If ManningDate.Value = "" Then
> BlankCounter = BlankCounter + 1
> Else
> BlankCounter = 0
> End If
>
> If BlankCounter > 15 Then
> Exit For
> Else
> '''Do more stuff here
> End If
>
> Next ManningDate
>
> Next SingleDate
>
> The error message is coming up on the second loop statement: For Each
> ManningDate In Sheets("Yearly Manning").Range(SingleDate.EntireColumn)
>
> What is wrong with using the entire column as my range? As you can I have a
> BlankCounter to get out of the loop once I go through enough blank rows.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange Errors...Don't Understand =?Utf-8?B?UGF1bCBCdXp6YSwgb2xkc3RlciB1c2luZyBuZXcg Microsoft ASP .NET 2 20th Aug 2007 01:54 PM
[Exceptions Handling] How to understand the different type of errors Starsky Microsoft Dot NET Framework 3 21st May 2007 05:58 PM
Access errors that I don't understand louise Microsoft Access Getting Started 4 24th May 2006 05:06 AM
Seagate drive check utility reports "errors in metadatea file records, other errors critical errors in metadata.." LQQK@mi.sig Storage Devices 0 3rd Feb 2006 04:48 AM
can't understand FBA errors Henry Markov Windows XP Embedded 2 23rd Feb 2004 04:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:38 AM.