PC Review


Reply
Thread Tools Rate Thread

What is the Cause of this Error Q

 
 
Sean
Guest
Posts: n/a
 
      23rd Sep 2007
I am hitting debug 1004

"Unable to get th SpecialCells property of the Range class"

Any suggestions on what is causing this and how do I amend?

Thanks

 
Reply With Quote
 
 
 
 
=?Utf-8?B?T3NzaWVNYWM=?=
Guest
Posts: n/a
 
      23rd Sep 2007
Hi Sean,

Need more info. Can you post your code please?

Regards,

OssieMac

"Sean" wrote:

> I am hitting debug 1004
>
> "Unable to get th SpecialCells property of the Range class"
>
> Any suggestions on what is causing this and how do I amend?
>
> Thanks
>
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      23rd Sep 2007
Is your worksheet protected?



Sean wrote:
>
> I am hitting debug 1004
>
> "Unable to get th SpecialCells property of the Range class"
>
> Any suggestions on what is causing this and how do I amend?
>
> Thanks


--

Dave Peterson
 
Reply With Quote
 
Sean
Guest
Posts: n/a
 
      23rd Sep 2007
On Sep 23, 1:34 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> Is your worksheet protected?
>
> Sean wrote:
>
> > I am hitting debug 1004

>
> > "Unable to get th SpecialCells property of the Range class"

>
> > Any suggestions on what is causing this and how do I amend?

>
> > Thanks

>
> --
>
> Dave Peterson



Code is pretty long, but see below, the problem area is in

.Range("AI3:AI4").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" Then
strto = strto & cell.Value & ";"

This is where is obtains an e-mail address (which on my sheet are
valid). It has worked fine in the past but now its suddenly thrown up
this error


Sub Mail_New_Version()
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim Sourcewb As Workbook
Dim Destwb As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim OutApp As Object
Dim OutMail As Object
Dim sh As Worksheet

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

Set Sourcewb = ActiveWorkbook

Sheets("E-Figures").Visible = True
Sheets("E-Access").Visible = True

Sheets("E-Figures").Select
ActiveSheet.Unprotect Password:="123"

'Copy the sheets to a new workbook
Sourcewb.Sheets(Array("E-Figures", "E-Access", "Rules")).Copy
Set Destwb = ActiveWorkbook

'Determine the Excel version and file extension/format
With Destwb
If Val(Application.Version) < 12 Then
'You use Excel 97-2003
FileExtStr = ".xls": FileFormatNum = -4143
Else
'You use Excel 2007
'We exit the sub when your answer is NO in the security
dialog that you only
'see when you copy a sheet from a xlsm file with macro's
disabled.
If Sourcewb.Name = .Name Then
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
MsgBox "Your answer is NO in the security dialog"
Exit Sub
Else
Select Case Sourcewb.FileFormat
Case 51: FileExtStr = ".xlsx": FileFormatNum = 51
Case 52:
If .HasVBProject Then
FileExtStr = ".xlsm": FileFormatNum = 52
Else
FileExtStr = ".xlsx": FileFormatNum = 51
End If
Case 56: FileExtStr = ".xls": FileFormatNum = 56
Case Else: FileExtStr = ".xlsb": FileFormatNum = 50
End Select
End If
End If
End With

' 'Change all cells in the worksheets to values if you want
' For Each sh In Destwb.Worksheets
' sh.Select
' With sh.UsedRange
' .Cells.Copy
' .Cells.PasteSpecial xlPasteValues
' .Cells(1).Select
' End With
' Application.CutCopyMode = False
' Destwb.Worksheets(1).Select
' Next sh

'Save the new workbook/Mail it/Delete it
TempFilePath = Environ$("temp") & "\"
TempFileName = "Part of " & Sourcewb.Name & " " & Format(Now, "dd-
mmm-yy hh-mm")

ActiveWindow.TabRatio = 0.908

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)


Sheets("E-Figures").Activate
Range("A1").Select

For Each cell In ThisWorkbook.Sheets("E-
Figures").Range("BJ1:BJ18")
strbody = strbody & cell.Value & vbNewLine
Next


For Each cell In ThisWorkbook.Sheets("E-Figures") _
.Range("AI3:AI4").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" Then
strto = strto & cell.Value & ";"
End If
Next
strto = Left(strto, Len(strto) - 1)

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      23rd Sep 2007
> > Is your worksheet protected?

Sean wrote:
>
> On Sep 23, 1:34 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:

<<snipped>>
 
Reply With Quote
 
Sean
Guest
Posts: n/a
 
      23rd Sep 2007
On Sep 23, 2:08 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> > > Is your worksheet protected?

> Sean wrote:
>
> > On Sep 23, 1:34 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:

>
> <<snipped>>


Dave it is but I unprotect it towards the start of the code

Sheets("E-Figures").Select
ActiveSheet.Unprotect Password:="123"

E-Figures is where the e-mail address in A13:AI4 reside, where I'm
having the problem


 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      23rd Sep 2007
If there are no constants in that range, then this will fail...

For Each cell In ThisWorkbook.Sheets("E-Figures") _
.Range("AI3:AI4").Cells.SpecialCells(xlCellTypeConstants)

Maybe you could check first

dim RngToCheck as range
....

set rngtocheck = nothing
on error resume next
set rngtocheck = ThisWorkbook.Sheets("E-Figures") _
.Range("AI3:AI4").Cells.SpecialCells(xlCellTypeConstants)
on error goto 0

if rngtocheck is nothing then
'what should happen
else
For Each cell In rngtocheck.cells
...



Sean wrote:
>
> On Sep 23, 2:08 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> > > > Is your worksheet protected?

> > Sean wrote:
> >
> > > On Sep 23, 1:34 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:

> >
> > <<snipped>>

>
> Dave it is but I unprotect it towards the start of the code
>
> Sheets("E-Figures").Select
> ActiveSheet.Unprotect Password:="123"
>
> E-Figures is where the e-mail address in A13:AI4 reside, where I'm
> having the problem


--

Dave Peterson
 
Reply With Quote
 
Sean
Guest
Posts: n/a
 
      23rd Sep 2007
On Sep 23, 4:49 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> If there are no constants in that range, then this will fail...
>
> For Each cell In ThisWorkbook.Sheets("E-Figures") _
> .Range("AI3:AI4").Cells.SpecialCells(xlCellTypeConstants)
>
> Maybe you could check first
>
> dim RngToCheck as range
> ...
>
> set rngtocheck = nothing
> on error resume next
> set rngtocheck = ThisWorkbook.Sheets("E-Figures") _
> .Range("AI3:AI4").Cells.SpecialCells(xlCellTypeConstants)
> on error goto 0
>
> if rngtocheck is nothing then
> 'what should happen
> else
> For Each cell In rngtocheck.cells
> ...
>
>
>
>
>
> Sean wrote:
>
> > On Sep 23, 2:08 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> > > > > Is your worksheet protected?
> > > Sean wrote:

>
> > > > On Sep 23, 1:34 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:

>
> > > <<snipped>>

>
> > Dave it is but I unprotect it towards the start of the code

>
> > Sheets("E-Figures").Select
> > ActiveSheet.Unprotect Password:="123"

>
> > E-Figures is where the e-mail address in A13:AI4 reside, where I'm
> > having the problem

>
> --
>
> Dave Peterson- Hide quoted text -
>
> - Show quoted text -


Dave, not entirely sure what you mean. The contents of the cells
AI3:AI4 are

'(E-Mail Removed)
'(E-Mail Removed)

but it still fails.

BTW it worked previously with no problems, but in doesn't any more

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      23rd Sep 2007
I'm saying that if that range AI3:AI4 contains formulas or is empty, then that
code will fail. It's looking for constants. If there are no constants, then it
won't work.

Maybe you should double check that range once more.

Sean wrote:
>
> On Sep 23, 4:49 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> > If there are no constants in that range, then this will fail...
> >
> > For Each cell In ThisWorkbook.Sheets("E-Figures") _
> > .Range("AI3:AI4").Cells.SpecialCells(xlCellTypeConstants)
> >
> > Maybe you could check first
> >
> > dim RngToCheck as range
> > ...
> >
> > set rngtocheck = nothing
> > on error resume next
> > set rngtocheck = ThisWorkbook.Sheets("E-Figures") _
> > .Range("AI3:AI4").Cells.SpecialCells(xlCellTypeConstants)
> > on error goto 0
> >
> > if rngtocheck is nothing then
> > 'what should happen
> > else
> > For Each cell In rngtocheck.cells
> > ...
> >
> >
> >
> >
> >
> > Sean wrote:
> >
> > > On Sep 23, 2:08 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> > > > > > Is your worksheet protected?
> > > > Sean wrote:

> >
> > > > > On Sep 23, 1:34 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:

> >
> > > > <<snipped>>

> >
> > > Dave it is but I unprotect it towards the start of the code

> >
> > > Sheets("E-Figures").Select
> > > ActiveSheet.Unprotect Password:="123"

> >
> > > E-Figures is where the e-mail address in A13:AI4 reside, where I'm
> > > having the problem

> >
> > --
> >
> > Dave Peterson- Hide quoted text -
> >
> > - Show quoted text -

>
> Dave, not entirely sure what you mean. The contents of the cells
> AI3:AI4 are
>
> '(E-Mail Removed)
> '(E-Mail Removed)
>
> but it still fails.
>
> BTW it worked previously with no problems, but in doesn't any more


--

Dave Peterson
 
Reply With Quote
 
Sean
Guest
Posts: n/a
 
      23rd Sep 2007
On Sep 23, 6:55 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> I'm saying that if that range AI3:AI4 contains formulas or is empty, then that
> code will fail. It's looking for constants. If there are no constants, then it
> won't work.
>
> Maybe you should double check that range once more.
>
>
>
>
>
> Sean wrote:
>
> > On Sep 23, 4:49 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> > > If there are no constants in that range, then this will fail...

>
> > > For Each cell In ThisWorkbook.Sheets("E-Figures") _
> > > .Range("AI3:AI4").Cells.SpecialCells(xlCellTypeConstants)

>
> > > Maybe you could check first

>
> > > dim RngToCheck as range
> > > ...

>
> > > set rngtocheck = nothing
> > > on error resume next
> > > set rngtocheck = ThisWorkbook.Sheets("E-Figures") _
> > > .Range("AI3:AI4").Cells.SpecialCells(xlCellTypeConstants)
> > > on error goto 0

>
> > > if rngtocheck is nothing then
> > > 'what should happen
> > > else
> > > For Each cell In rngtocheck.cells
> > > ...

>
> > > Sean wrote:

>
> > > > On Sep 23, 2:08 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> > > > > > > Is your worksheet protected?
> > > > > Sean wrote:

>
> > > > > > On Sep 23, 1:34 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:

>
> > > > > <<snipped>>

>
> > > > Dave it is but I unprotect it towards the start of the code

>
> > > > Sheets("E-Figures").Select
> > > > ActiveSheet.Unprotect Password:="123"

>
> > > > E-Figures is where the e-mail address in A13:AI4 reside, where I'm
> > > > having the problem

>
> > > --

>
> > > Dave Peterson- Hide quoted text -

>
> > > - Show quoted text -

>
> > Dave, not entirely sure what you mean. The contents of the cells
> > AI3:AI4 are

>
> > 'joe.blo...@abc.com
> > 'jack.blo...@abc.com

>
> > but it still fails.

>
> > BTW it worked previously with no problems, but in doesn't any more

>
> --
>
> Dave Peterson- Hide quoted text -
>
> - Show quoted text -


Definitely Dave, there are values in AI3:AI4 in sheet E-Figures

 
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
Server Error: 451, Socket Error: 10053, Error Number: 0x800CCC0F =?Utf-8?B?RGFuaWVsYQ==?= Windows XP Help 3 17th Aug 2007 05:10 PM
Access error 3197 and JETCOMP.exe error "Error compacting database =?Utf-8?B?Vmlja3k=?= Microsoft Access 2 21st Jul 2007 12:29 AM
Error connecting to SQLExpress 2005 locally (error: 26 - Error Locating Server/Instance Specified) hfk0 Microsoft ASP .NET 2 27th Mar 2006 09:43 PM
3 Problems - Media Center Error, Date/Time Error, Downloading Updates Error angieangie Windows XP General 0 23rd Dec 2005 06:33 PM
A runtime error has occured. Do you want to debug? Line: 1 Error: syntax error Eric Windows XP Networking 0 24th Nov 2003 03:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:17 PM.