Endless Loop? (stops Responding)

Jun 15, 2009

Having another problem with the same macro that has been giving me trouble for a week now. Now, the macro will run, but after it finishes, excel stops responding. Is this because the macro continues to run indefinitely.

View 3 Replies


ADVERTISEMENT

Endless Loop With While

May 16, 2007

Why does my Excel hang on this

While TempWaarde1 <> ""

TempWaarde1 = Cells.Value(Posi, 1)
TempWaarde2 = Cells.Value(Posi - 1, 1)

If TempWaarde1 <> TempWaarde2 Then
ListBox1.AddItem TempWaarde1
End If

Posi = Posi + 1
Wend

What I'm trying to achief is to fill a listbox with all values in the first column of the active sheet, but avoiding double entry's if they're on the row after the 1st one. When I execute this in my Userform_Initialize, Excel hangs like the while-wend loop is never finishing, while i'm sure there is no more data in the 1st column after 200 rows or so.

View 3 Replies View Related

Endless Loop & Macros

Apr 27, 2009

I've used a loop in one of my macros and the loop goes on endlessly. I've been trying to come up witha way to overcome this problem but with no luck till now. knowing that I'm new to VBA i decided to turn to the big guns at mr.exxcel to help me out. Here's the code i have. Any alternatives to this would be VERY VERY VERY USEFUL!!!

Sub smalloops()
Dim i As Integer
Dim compliant As Integer
Dim noncompliant As Integer

compliant = 0
noncompliant = 0
For i = 1 To 60

Do Until Cells(i, 2) = ("RECOMMENDATIONS")

Do While Cells(i, 3) 0
If Cells(i, 7) = 1 Then
compliant = compliant + 1
ElseIf Cells(i, 7) = 2 Then.................

View 9 Replies View Related

Stopping An Endless Loop

Dec 21, 2006

I have the following VBA in the attatched spreadsheet (seperated so I could upload)

The only problem that I have is that I cannot stop the loop, it constantly keeps going round in a circle.

What im wanting to do is when the Date checked is the End date and the End Time has been checked, to move onto the next row and do it again until it gets to row 40.

Sub Calculate()
Dim CellNo As Integer
Dim CurrentDate As Date
Dim StartDate As Date
Dim EndDate As Date
Dim theDate As String
Dim c As Range
Dim i As Integer
Dim addDate As Integer
Dim DaysHoursSick As Date
Dim StartWorkTime As Date
Dim EndWorkTime As Date
Dim endmarker As String

I've only got this VBA working really under Wednesday so I can make sure it is right before adding it onto the other dates,

View 4 Replies View Related

Macro Triggered By Worksheet Activate - Endless Loop

Oct 25, 2011

I have a multi-sheet workbook. The first sheet is a summary of results from the rest of the workbook. I would like this summary sheet to auto-refresh itself each time the sheet is activated. The VBA code triggered by the Worksheet/Activate event feeds some parameters out to other sheets, then copies back the results to the summary sheet of the workbook.

While doing so, it keeps "reactivating" the first sheet, causing it to get into an endless loop that is triggered by the Worksheet/Activate event. Essentially, I'd like the Worksheet/Activate event to go dormant for 15 seconds or so each time it is triggered.

View 3 Replies View Related

Excel 2007 :: VBA - Finding Endless Loop In Long Routine?

May 14, 2014

I have a very long routine, looping through 35,000-ish rows several times to detect and delete unwanted items. Occasionally, it gets locked into an endless loop and CTRL+Break will not stop it - I have to kill Excel through the Task Manager.

How can I find out where the endless loop is so I can detect what's causingit and fix it?

View 6 Replies View Related

Vba: Why There Is An Endless Loop When For Each Cell In Range Includes Merged Cells

Aug 6, 2008

When I set a "for each cell in range" to go through the range, and if there are merged cells in this range, this will result an endless loop.

View 9 Replies View Related

Endless Loop Within A Loop

Oct 28, 2006

I have loops working in other loops. The macro is almsot working well. It does the calculation i want but it fails to stop a loop, because of that, the macro can't run the next main loop (c), which is to move to the next cell where the calculations must be run.

I attach a file. the troubleshooting macroation is Sub Itiration.

The code of this macro are bellow. Basically, the loop using d as counter run into an endless loop. I don't how to stop this loop without affecting the results which are calculated correctly.

Sub Itiration()
Dim CurCell As Object
Dim TempSum As Double
Dim d As Integer

For c = 3 To Cells(3, 4)
If Cells(11, c) > 0 Then
For i = 1 To Cells(10, c)
Do

View 9 Replies View Related

Code Stops During The Loop

Apr 9, 2009

I am using Excel 2003 work PC, and when i run this simple code it stops during the loop, I have had this problem a bit its like something is hitting the esc key or ctrl - break. But no keys are being hit or are sticking.

I have closed Excel and created new work book pasted the code in but it still stops at r = r - 1, haven't done a restart yet.

Sub Macro2()
Dim r As Integer
r = 10
Do Until r = 0
ActiveCell.Value = ("Shut down in " & r)
Application.Wait Now + TimeValue("0:00:01")
r = r - 1
Loop
Application.Quit
End Sub

View 9 Replies View Related

Loop Stops Prematurely

Jan 7, 2007

I have the following code that loops through a series of data creating a covariance matrix. For some reason the loop only runs through 4 iterations and then stops. I cannot for the life of me figure out what is wrong. Any thoughts? Truncated example workbook also attached....

Sub covarmatrix()
Dim Series1 As Range
Dim Series2 As Range
Dim i As Integer
i = 0
Sheets("rawdata").Select
Do
Set Series1 = Sheets("rawdata").Range(Range("B3").Offset(0, i), Range("B65536").End(xlUp).Offset(0, i))
j = 0
Do
Set Series2 = Sheets("rawdata").Range(Range("B3").Offset(0, j), Range("B65536").End(xlUp).Offset(0, j))..............................

View 8 Replies View Related

Loop Stops Early

Jan 22, 2007

verify that this syntax is correct. I just started working with Charts in VBA and it is getting very frustrating. This code should be able to run up to 140 cycles but it quits making charts at 7. Something I'm missing? If it is of any relevance sometimes it errors out at the HasTitle and Legend properties.

Dim myChtObj As ChartObject
Dim rngChtData As Range
Dim rngChtXVal As Range
Dim rng As Range
X = 0
y = 2
z = 1

Do Until y = 8

Set rngChtData = ActiveSheet.Range("A2:A352").Offset(0, z)

View 9 Replies View Related

Create A Loop Which Stops Once A Cell Is Empty

Mar 11, 2009

I am trying to create a loop which stops once a cell is empty.

Assuming I have declared proper DIM, my code is

Row=1

Do
Row = Row + 1
SheetName = Cells(Row, "A")
Sheets.Add.Name = SheetName
Loop Until IsEmpty(SheetName.Offset(1, 0))

View 9 Replies View Related

Loop To Delete Worksheets Stops After Deleting One Sheet

Mar 17, 2014

Sub DeleteSheetsPlease()

Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
Application.StatusBar = "checking " & ws.Name

[code] .......

This skips "Parameters" and "About", then it deletes a single sheet (that does not match "Parameters" or "About"),

BUT THEN IT STOPS, leaving "deleting [WSNAME]" in the appstatus. It's like it skips the "Next ws" statement altogether after deleting a sheet.

I want it to keep looping on all the sheets, but that delete action seems to kill the looping...

View 2 Replies View Related

Create An Endless Column Of Numbers And Check Boxes

Aug 8, 2007

I have some code which, which I have modified it to create check boxes for all rows of data, but when I run it, it begins to wipe out the data, and create an endless column of numbers and check boxes. Here is the code:

Sub SelectCell()
Application. ScreenUpdating = False
Dim Z As Range
Set Z = Cells(1, 1).EntireColumn. Find("*", SearchDirection:=xlPrevious)
For i = 2 To Z
Range("A" & i) = i
Set cll = Range("A" & i).Offset(0, 1)
For Each shp In ActiveSheet.Shapes
If Left(shp.Name, 8) = "CheckBox" And shp.TopLeftCell.Address = cll.Address Then
shp.Delete
Exit For.......................

I have tried to set it to recognize how many rows are filled with number, give that to variable Z and then apply the code but it simply does not work.

View 7 Replies View Related

Cell Is Not Responding?

Oct 1, 2012

Some times the cell having formula, is not calculating , i need to click F2 then enter to get the real calculation. Why this is happening and how to avoid it?

View 1 Replies View Related

Worksheet Event Not Responding

Jul 25, 2009

I have created a chart with four data ranges. I have a check box for the four ranges. If a check box is TRUE the data is shown in the chart. When I check one of the check boxes, I want the CreateChart macro to run, but this is not happening with the code below?

View 4 Replies View Related

Before Print Event Not Responding

Jan 9, 2007

I have a Word document that I'd like to print first, when I click Print on a specific worksheet (not on Print of other worksheets in the workbook, just the one). The worksheet contains customer information and is essentially a cover page for the Word document. the Word document already prints in reverse order, as does the worksheet, so I just need the Word doc to print prior to the worksheet/cover, to give me the total print package in the correct order. I've tried using the following code in the Sheet object for the worksheet in question;

Private Sub Worksheet_BeforePrintEvent()
Dim appWd As Word.Application
Set appWd = CreateObject("Word.Application")
appWd.Visible = True 'Change to False when code is good
'Open Doc
appWd.Documents.Open Filename:="S:BryanQuoting ToolsP'Binder Leading Pages.doc"
'Print Doc
appWd.ActiveDocument.PrintPreview 'Change to PrintOut when code is good
'Close Doc
Set appWd = Nothing
End Sub

View 7 Replies View Related

Application.quit Not Responding

Apr 17, 2007

I have this I found here and want it to close down excel as well but its not working and not sure why.

I have a command button tied to this: ....

View 6 Replies View Related

Macro Not Responding To Cell Deletion

Nov 12, 2008

if column E is "Annuity", you can type a value in column J and it runs a formula to calculate a value for column K. If E is not "Annuity" it clears the contents of J (which should clear K). What's not working is when column J gets cleared or manually deleted, column K must be blank. The worksheet_change event is not working for deletion of column J.

View 5 Replies View Related

VBA Code - How To Skip Macro While Not Responding

May 16, 2012

I have create excel VBA to put data from excel sheet to Server database through network. I create the VBA on the "Workbook_beforeprint" so every time the user print out the sheet, the code will run.

Problem occur when there is no network and excel application become not responding.

I want to make VBA code so that every time excel application become not responding because no network, this code will bypass the existing VBA and resume to print.

View 4 Replies View Related

Excel 2010 :: Keeps Crashing And Not Responding Or Saving?

Mar 9, 2012

I have a genuine copy of office pro 2010. All works fine except excel!

It seems to be mainly on one workbook I have brought over from open office and on a mac! It wont save due to errors it won't tell you about? It then stops responding or crashes? Wont save as etc....

I have repaired, I have even deleted and downloaded a new office pro genuine and installed and doing the same so i guess it has to be the file?

BUT it seems to work on another laptop we have, same file, same excel????

The only thing i seem to be able to find is in the permissions it has an "unknown account"? Also under the file menu where it allows you to check the file it states something about conditional formatting i have used and not being compatible BUT i cant for the life of me find that in the menus to get rid?

View 10 Replies View Related

Cells Not Responding To Left, Right, Center Arrangment

Jan 19, 2010

I think I did something but I don't know What. I select a cell that has a 20 font Size I enter a number it show at the 20 Font. Now when I go some ware else in the work unselecting that cell the number went to font 10 and droped to the left bottom of the cell. When I select the cell again and select the the left middle and right to move the number it does not responed. It happens everyware in the worksheet.

View 14 Replies View Related

Combobox Not Responding - Imbedded Directly In Worksheet

Jan 25, 2012

I am working on a macro that runs when a combobox is clicked. The combobox is imbedded directly in the worksheet, not in a form.

Basically, the user clicks the down arrow on the combobox, selects one of the available choices, and the choice selected is written to the spreadsheet - each time the selection is made, it is written to a successive row in the spreadsheet - keeping track of every selection made.

The macro works, mostly. But problem is that if the user repeats a selection in the combobox (makes a choice, and then in the next cycle makes the same choice) the macro doesn't run - nothing happens.

Here is the code:

Private Sub ComboBox1_Change()
i = Cells(2, 4) ' value in cell D2
Cells(i, 6) = Cells(4, 9) ' selected value from cobobox stored in cell I4
' This value copied to column F - successive rows
i = i + 1 ' counter to increment row for next value
Cells(2, 4) = i ' Update cell D2 with new i value
End Sub

View 4 Replies View Related

Workbook Causing Intermittent Freeze & Not Responding

Dec 31, 2008

I recently added some command buttons to 6 excel files each with about 20 sheets. most of the sheets got 6 new buttons. After I added the buttons I would get memory errors when I treied to open other files. So I upgraded to Office 2003 and Excel 2003 because I read that it had increased memory available. It did not seem to help much, and now on average about evry say 10 minutes Excel hangs for about 1o seconds, sometimes saying "Not Responding" up the top. Then it starts working again. MY PC has Server 2003 and 1GHz and 512MB of Ram. Here is some info:

=INFO("memavail")1048576
=INFO("memused")50769256
=INFO("totmem") 51817832
=INFO("numfile") 173
=INFO("osversion")Windows (32-bit) NT 5.02
=INFO("release") 11.0

I do not think the PC memory or chip is being stressed it seems to be Excel's memory?

View 4 Replies View Related

Form Controls / Objects / Images Disappearing Not Responding

Aug 10, 2014

My form controls (cmd buttons) and images don't appear or don't work. I was working on a macro to cut and paste a set of cells (protected sheet, I did unprotect it), and I noticed the cmd button tied to this disappeared. It then re-appeared but I couldn't engage it. This is part of a larger workbook that consists of a single page of cmd buttons that release specific worksheets (no activex). These buttons disappeared and re-appeared and don't work either. When I select the button I can see the cell underneath light up. It's like the image is there but nothing else?

The macros run fine from VBA editor. I was thinking the issue had something to do protections? There are more than 5 passwords (set on a worksheet) being used here, there is a fair amount of protecting and unprotecting going on, and I loop through the worksheets several times. Everything was working fine and now I'm stuck. I was getting a the-object-invoked-has-disconnected-from-its-client error related to an "insert cells" command on a co-workers computer, but not on my machine. This is actually what I was trying to solve when it crapped out. I would delete the buttons and create them all again, but I can't even select them to delete them.

View 5 Replies View Related

Worksheet Change Event Not Responding To Cell Deletion ...

Nov 13, 2008

I have a code where column K is not responding to a value being deleted out of column J. I've highlighted the portion of the code dealing with this. Deletion should trigger the worksheet_change event to clear out column K as it's supposed to. how to get deletion to take effect?

View 4 Replies View Related

Worksheet Change Event Not Responding To Cell Deletion

Nov 14, 2008

This is part of a macro in a worksheet_change event. When a cell in column J gets deleted by a user, the corresponding cell in column K should also clear. But it's not responding to the delete.

It DOES clear when the other 2 criteria are met (.cells(1,10) = 0 and .cells(i,5) <> "Annuity"). The worksheet_change event should pick up on the cell deletion, but it's not. And column J is already a trigger for the macro to run, so I'm not sure what's going on. Either the trigger is still wrong, the isempty(.cells(i,10)) is not correct syntax, or this event just doesn't respond to cell deletion.

View 6 Replies View Related

Not Responding: Added A Formula To A Spreadsheet With Som Complicated Formula

Jun 1, 2006

I recently added a formula to a spreadsheet with som complicated formula. It worked ok and I saved the sheet. Now it takes 5 minutes to open the sheet and when I try to do anything,like delete the inserted column the program locks up giving a no responding message. I can do without this column if I have to.

View 4 Replies View Related

Macro Stops In The Last Row

Feb 25, 2009

The macro stops in the last row - it isn't able to select a cell in another sheet than "Menu" (I tested it different variations).

View 9 Replies View Related

VBA Code Stops

Dec 14, 2007

My code below works great all the way to the end. When the last message box comes up, If the user chooses Yes. I want them to be directed to the sheet "C123". But currently it just stays on the sheet that I named "Home".

What am I missing here?

Private Sub CommandButton1_Click()

Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Log")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'check for a Reason Code
If Trim(Me.ComboBox2.Value) = "" Then
Me.ComboBox2.SetFocus
MsgBox "Please enter a reason code and ensure that date is correct!"
Exit Sub
End If

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved