Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Rob Rob is offline
external usenet poster
 
Posts: 718
Default Out of Stack space - run time error 28

I am trying to run a macro in Excel and keep running out of Stack space can
anyone see what is wrong (probably a lot) with this macro.

Sub Macro2()
'
' Macro2 Macro
' Macro recorded 17/12/2007 by RLamb2
'

'
Range("A2").Select
Application.Run "'Export from APC.xls'!Changelength"
End Sub

Sub Changelength()

If Len(ActiveCell) = 0 Then
Application.Run "'Export from APC.xls'!Extractdate"
End If
If Len(ActiveCell) = 4 Then
Selection.Offset(1, 0).Select
End If
If Len(ActiveCell) = 3 Then
ActiveCell.Formula = "'0" & ActiveCell.Formula
End If
Selection.Offset(1, 0).Select
Application.Run "'Export from APC.xls'!Checklength"

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 533
Default Out of Stack space - run time error 28

The sub can't just keep calling itself. Check your logic.

Sub CallMe()
CallMe
End Sub

--
Jim
"Rob" wrote in message
...
|I am trying to run a macro in Excel and keep running out of Stack space can
| anyone see what is wrong (probably a lot) with this macro.
|
| Sub Macro2()
| '
| ' Macro2 Macro
| ' Macro recorded 17/12/2007 by RLamb2
| '
|
| '
| Range("A2").Select
| Application.Run "'Export from APC.xls'!Changelength"
| End Sub
|
| Sub Changelength()
|
| If Len(ActiveCell) = 0 Then
| Application.Run "'Export from APC.xls'!Extractdate"
| End If
| If Len(ActiveCell) = 4 Then
| Selection.Offset(1, 0).Select
| End If
| If Len(ActiveCell) = 3 Then
| ActiveCell.Formula = "'0" & ActiveCell.Formula
| End If
| Selection.Offset(1, 0).Select
| Application.Run "'Export from APC.xls'!Checklength"
|
| End Sub


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Out of Stack space - run time error 28

What is your stopping criteria. There is nothing that stops this from
running. You have an infinite loop. As guess you are trying to loop through
all of the cells in Column A until you run out of data. If that is the case
then try somethying more like this...

sub WhatEver()
dim rng as range
dim rngToSearch as Range

set rngtosearch = range(range("A2"), cells(rows.count, "A").end(xlup))

for each rng in rngtosearch
with rng
select len(rng)
case 0
call extractdate
case 3
rng.formula = "'0" & rng.formula
end select
end with
next rng
end sub
--
HTH...

Jim Thomlinson


"Rob" wrote:

I am trying to run a macro in Excel and keep running out of Stack space can
anyone see what is wrong (probably a lot) with this macro.

Sub Macro2()
'
' Macro2 Macro
' Macro recorded 17/12/2007 by RLamb2
'

'
Range("A2").Select
Application.Run "'Export from APC.xls'!Changelength"
End Sub

Sub Changelength()

If Len(ActiveCell) = 0 Then
Application.Run "'Export from APC.xls'!Extractdate"
End If
If Len(ActiveCell) = 4 Then
Selection.Offset(1, 0).Select
End If
If Len(ActiveCell) = 3 Then
ActiveCell.Formula = "'0" & ActiveCell.Formula
End If
Selection.Offset(1, 0).Select
Application.Run "'Export from APC.xls'!Checklength"

End Sub

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
"Out of Stack Space" Macro Error Adam Excel Discussion (Misc queries) 3 July 2nd 07 07:10 PM
I need to add space to convert DATE to TIME format Wannano Excel Discussion (Misc queries) 9 April 11th 07 07:08 PM
Avoiding Value error message due to space in cell w/ formula A.R. Hunt Excel Discussion (Misc queries) 3 January 26th 07 09:52 PM
Exceeded font space error message thirtywinter Excel Discussion (Misc queries) 0 September 22nd 06 11:35 AM
Run time error 1004, General ODBC error [email protected] New Users to Excel 0 September 19th 05 01:41 AM


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