Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Runtime Error

Hello, I realize this may not be the best code in the world but it works
till the end when I get a runtime error.

I have a column of a series of 1's and 0's - as in 20 consecutive 1's
followed by 100 consecutive 0's followed by 40 consecutive 1's etc. I want
the macro to locate the last 1 (or first 0) in the series and then run a
macro. My macro works until it gets to the last set of 0's and can't find a
1. Any help greatly appreciated!

Sub FillLowTotal()

Application.ScreenUpdating = False
Range("e5").Select
Do
Do Until ActiveCell = 0
ActiveCell.Offset(1, 0).Range("A1").Select
Loop
ActiveCell.Select
ActiveSheet.Application.Run ("Lowtotal")
Range(Selection, Selection.End(xlDown)).Select
Selection.Find(What:="1", After:=ActiveCell, LookIn:=xlValues,
LookAt:= _
xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:=False).Activate
Loop Until IsEmpty(ActiveCell.Value)
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Runtime Error

Your find is going to be an issue if it does not find anything to activate.
You might be able to get away with addin the line

On Error Resume Next

At the beginning of your code...
--
HTH...

Jim Thomlinson


"xgirl" wrote:

Hello, I realize this may not be the best code in the world but it works
till the end when I get a runtime error.

I have a column of a series of 1's and 0's - as in 20 consecutive 1's
followed by 100 consecutive 0's followed by 40 consecutive 1's etc. I want
the macro to locate the last 1 (or first 0) in the series and then run a
macro. My macro works until it gets to the last set of 0's and can't find a
1. Any help greatly appreciated!

Sub FillLowTotal()

Application.ScreenUpdating = False
Range("e5").Select
Do
Do Until ActiveCell = 0
ActiveCell.Offset(1, 0).Range("A1").Select
Loop
ActiveCell.Select
ActiveSheet.Application.Run ("Lowtotal")
Range(Selection, Selection.End(xlDown)).Select
Selection.Find(What:="1", After:=ActiveCell, LookIn:=xlValues,
LookAt:= _
xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:=False).Activate
Loop Until IsEmpty(ActiveCell.Value)
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Runtime Error

Thanks for the tip Jim. After playing around with that idea I was able to
get it to run using the following...

On Error GoTo Finished
Finished:
MsgBox "Complete"
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
xpath error? Runtime Error 13 type mismatch SteveM Excel Discussion (Misc queries) 1 December 4th 07 09:16 AM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
naming tab macro error runtime error 1004 D Excel Programming 3 February 28th 05 01:32 AM
Interior class error/runtime error 1004 David Goodall Excel Programming 1 October 24th 04 10:16 PM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM


All times are GMT +1. The time now is 01:52 PM.

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"