Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Excel 2002 and 97 compatability



I have written a simple bit of code that works perfectly on my machine
(PC with XP and Excel 2002). When I send it to a friend with Excel 97
he gets a 'runtime 13 error', presumably because he has an older version
of Excel.

Is there anyway of finding out what is causing the problem so that I can
re-code the VBA macro another way?

The code is simply:

Sub Macro1()
For Each blankcell In Range("M2:M10000")
If blankcell.Value < 0 Then
blankcell.Offset(0, 3).Activate
Selection.Resize(1, 38).Select
Selection.SpecialCells(xlCellTypeConstants,2).Sele ct
Selection.Copy
Selection.End(xlToRight).Select
Selection.Offset(0, 1).Activate
ActiveSheet.Paste
Application.CutCopyMode = False
End If
Next blankcell
Columns("P:BB").Select
Selection.EntireColumn.Hidden = True
Range("A2").Select
End Sub



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Excel 2002 and 97 compatability

This line of code will cause that problem if blankcell does not contain a
number:

If blankcell.Value < 0 Then

Sub Macro1()
For Each blankcell In Range("M2:M10000")
if blankCell < "" and isnumeric(blankcell) then
If blankcell.Value < 0 Then
blankcell.Offset(0, 3).Activate
Selection.Resize(1, 38).Select
Selection.SpecialCells(xlCellTypeConstants,2).Sele ct
Selection.Copy
Selection.End(xlToRight).Select
Selection.Offset(0, 1).Activate
ActiveSheet.Paste
Application.CutCopyMode = False
End If
End if
Next blankcell
Columns("P:BB").Select
Selection.EntireColumn.Hidden = True
Range("A2").Select
End Sub

Should work. Guessing and the conditions you want to impose, so check the
logic - but you want to avoid doing a numeric comparison unless the cell
contains a number. Just as a warning, you can not do something like this

If isnumeric(blankcell) and blankcell < 0 then

because the line is fully evaluated and you would still get the error on the
second condition.

This is caused by xl97.

Regards,
Tom Ogilvy


"Andy" wrote in message
...


I have written a simple bit of code that works perfectly on my machine
(PC with XP and Excel 2002). When I send it to a friend with Excel 97
he gets a 'runtime 13 error', presumably because he has an older version
of Excel.

Is there anyway of finding out what is causing the problem so that I can
re-code the VBA macro another way?

The code is simply:

Sub Macro1()
For Each blankcell In Range("M2:M10000")
If blankcell.Value < 0 Then
blankcell.Offset(0, 3).Activate
Selection.Resize(1, 38).Select
Selection.SpecialCells(xlCellTypeConstants,2).Sele ct
Selection.Copy
Selection.End(xlToRight).Select
Selection.Offset(0, 1).Activate
ActiveSheet.Paste
Application.CutCopyMode = False
End If
Next blankcell
Columns("P:BB").Select
Selection.EntireColumn.Hidden = True
Range("A2").Select
End Sub



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default Excel 2002 and 97 compatability

Excel 97 does not recognize "blankcell". It needs to be defined.
Recommend
Dim blankcell as Range

Also this line will error out if there is nothing there,
Selection.SpecialCells(xlCellTypeConstants,2).Sele ct

recommend an error check.

steve

"Tom Ogilvy" wrote in message
...
This line of code will cause that problem if blankcell does not contain a
number:

If blankcell.Value < 0 Then

Sub Macro1()
For Each blankcell In Range("M2:M10000")
if blankCell < "" and isnumeric(blankcell) then
If blankcell.Value < 0 Then
blankcell.Offset(0, 3).Activate
Selection.Resize(1, 38).Select
Selection.SpecialCells(xlCellTypeConstants,2).Sele ct
Selection.Copy
Selection.End(xlToRight).Select
Selection.Offset(0, 1).Activate
ActiveSheet.Paste
Application.CutCopyMode = False
End If
End if
Next blankcell
Columns("P:BB").Select
Selection.EntireColumn.Hidden = True
Range("A2").Select
End Sub

Should work. Guessing and the conditions you want to impose, so check the
logic - but you want to avoid doing a numeric comparison unless the cell
contains a number. Just as a warning, you can not do something like this

If isnumeric(blankcell) and blankcell < 0 then

because the line is fully evaluated and you would still get the error on

the
second condition.

This is caused by xl97.

Regards,
Tom Ogilvy


"Andy" wrote in message
...


I have written a simple bit of code that works perfectly on my machine
(PC with XP and Excel 2002). When I send it to a friend with Excel 97
he gets a 'runtime 13 error', presumably because he has an older version
of Excel.

Is there anyway of finding out what is causing the problem so that I can
re-code the VBA macro another way?

The code is simply:

Sub Macro1()
For Each blankcell In Range("M2:M10000")
If blankcell.Value < 0 Then
blankcell.Offset(0, 3).Activate
Selection.Resize(1, 38).Select
Selection.SpecialCells(xlCellTypeConstants,2).Sele ct
Selection.Copy
Selection.End(xlToRight).Select
Selection.Offset(0, 1).Activate
ActiveSheet.Paste
Application.CutCopyMode = False
End If
Next blankcell
Columns("P:BB").Select
Selection.EntireColumn.Hidden = True
Range("A2").Select
End Sub



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





Reply
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
Excel 2007 & 1997 compatability realroadking Excel Discussion (Misc queries) 1 January 16th 10 05:51 PM
excel compatability stew Excel Discussion (Misc queries) 1 June 10th 09 02:08 PM
Excel Compatability mode?????? Terry Excel Discussion (Misc queries) 0 December 6th 08 09:13 PM
Excel 07 compatability checker Dave F[_2_] Excel Discussion (Misc queries) 0 February 21st 08 01:54 PM
Excel 2007 Compatability Tintin Excel Discussion (Misc queries) 0 June 5th 06 05:19 AM


All times are GMT +1. The time now is 06:24 PM.

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

About Us

"It's about Microsoft Excel"