Custom Sort Macro Causing Excel To Crash?

Jul 10, 2012

I am trying to sort a bunch of data by a custom list from left to right and after running the macro successfully excel crashes upon saving. I have tried this on different computers, resaved, started from scratch and it always crashes so there must be something with the macro that is causing this.

here is my macro:

Edit: It seems that the last line of code is causing my problem. I have started from scratch and gone though all the code one at a time and saved after each run. everything is fine until the "Application.DeleteCustomList Application.CustomListCount" is run. after that excel crashes when saved.

VB:
Sub Macro3()
'
' Macro3 Macro
'

[Code]....

View 1 Replies


ADVERTISEMENT

ClearContent Macro Causing Excel Crash?

Feb 22, 2014

Have a code to clear contents on one of my worksheets and it continually causes excel to freeze and forces me to exit the program. When the button is selected it takes approx. 30-45 seconds to clear the data and then excel freezes up. The code is as follows:

Sub()
Sheets("Sheet1").Range("B2:D16000").ClearContents
End Sub

The data in the range B2:D16000 comes from another macro that copies and pastes values to this sheet. I am also working on the mac 2011 version.

View 5 Replies View Related

VBA Causing Excel To Crash?

Apr 15, 2014

I have a piece of code in one of my Macro's, if I run the macro and don't let this piece of code run everything works fine, when I let this piece of code execute the excel file keeps running until I go to save, at which point I get a message saying "Microsoft office excel has encountered a problem and needs to close. We are sorry for any inconvenience".

Code is as follows:

If MsgBox("Copy and hardcode this scenario?", vbYesNo) = vbYes Then
Calculate
Application.DisplayAlerts = False

[Code]....

View 3 Replies View Related

Object Invoked Error Causing Excel To Crash

Jul 14, 2014

I am receiving the following error:

-2147417848 automation error the object invoked has disconnected from its clients

Unfortunately, I can't tell where the error is occurring because everytime it happens excel crashes or at least stops responding. I tried waiting it out (about 20 minutes) but no luck. the only thing I can do is force the program to shut down through the task manager.

The program is designed to pull information from finviz.com (a financial site), filter the data. pull the next round of data and run the filters again. there are a total of 8 queries and i think it gets hung up during the 6th or 7th run through.

Stepping through the code does not seem practical since each query might pull as many as 300 rows of data that is evaluated in a for/next loop (thats a lot of F8s).

View 5 Replies View Related

Macro Causing Custom Function To Fire

Sep 3, 2007

I have a large file, part of which amongst other things calculates life expectancy from a range of q(x) values (proportion of people that die moving from age (x) to (x+1). Life expectancy is calculated using a user-defined function (below).

My problem is that whenever I run a macro that changes the file, even parts of the file that don't affect the cells using the life function, it jumps into the life function. (An example: copying and pasting values on a different sheet). This is a hassle when stepping through other macros using F8, not to mention the time cost.

Some further possibly necessary information: one macro uses the GoalSeek application to set the target cell that contains the life function

By the way, this didn't use to happen in older versions of a similar file. When running the GoalSeek macro to change target life expectancy it did, but not for any other macro.

Here is the function:

Function life(data As Range)

' Aims to calculate Life expectancy from Qx values
' It assumes first value of Q is Qb, then Q0 to Qmax

Dim Nobs As Integer
Dim j As Integer, i As Integer
Dim q() As Double
Dim L() As Double
Dim T As Double, le As Double

Nobs = data.Rows.Count

View 9 Replies View Related

Worksheet Listbox Causing Crash With Mouse Wheel Scroll

Aug 21, 2008

I am having problems with an Excel workbook I am working on. I have a sheet that has a number of controls added to the top of it. Two of these controls are listboxes. My problem is, if I am in the listbox navigating through it, and I accidently move the Mouse Wheel, Excel crashes and I get the usual, "Send Error Report" form.

I have seen that there are other people having this problem and that there are a number of solutions out there but my problem is a bit different. I have a few forms with listboxes on them, and while mouse wheel scrolling doesn't work, it certainly doesn't crash Excel. It only seems to happen when I have a control permanently added to the sheet. Is there any event handler for mouse wheel scrolls or anyway to disable them through VB?

View 2 Replies View Related

Excel 2007 :: Custom Sort Column With Macro Button

Jun 20, 2013

I already have a Macro button built that hides values in column A. The next step I am trying to perform is a custom sort on column B in this order "Backordered", "Sourced", Shipped", and "Received". Here is my code that I have so far but where to begin adding in code to make this button sort.

Sub Inbound()
ActiveSheet.Cells.EntireColumn.Hidden = False
ActiveSheet.Cells.EntireRow.Hidden = False
Application.ScreenUpdating = False

[Code] ........

Excel 2007/Windows 7

View 1 Replies View Related

Custom Functions Causing Slow Calculations

Jan 11, 2010

I have a spread sheet that contains many user defined functions from a 3rd party provider that downloads financial data from an external database. Often not all of the data is required by the user, and as the UDF's take a long time to calcuate, i'd like to provide the ability to easily switch them on and off. Originally I had been looping through cells and either adding an apostrophe in front of the = or removing it. However running this loop is very slow.

I found this thread
(Optimize VBA Loop For Inserting Formula)
and adapted it to convert formula strings (with ' in front) to formulas in a single pass by setting:

myRange.formula = myRange.value. This works very well. I can't, however, work out how to go back the other way in a single pass. Have tried: myRange.formula = "'" & myRange.formula. This works for individual cells, but not for more than one at a time.

View 3 Replies View Related

Using Custom Sort List Within Macro

Aug 3, 2009

I have following code, which sorts data if user "double clicks" on cells A1, B1, C1, or D1. If the user "double clicks" on cell D1, I want to sort by column D but I want to apply a custom list. The data is in the "Custom Lists" table but I can't figure out how to apply to my code.

The sequence/sort order of the list is as follows:
aaa+, aaa, aaa-, aa+, aa, aa-, a+, a, a-, bbb+, bbb, bbb-, bb+, bb, bb-, b+, b, b-, ccc+, ccc, ccc-, cc+, cc, cc-, c+, c, c-, ddd+, ddd, ddd-, dd+, dd, dd-, d+, d, d-
code is as follows:

View 3 Replies View Related

Using Two Custom Sort Lists In Macro.

Aug 4, 2009

This is somewhat related to a post I had submitted previously but a bit more complex http://www.excelforum.com/showthread.php?p=2139259. I have following code, which sorts data if user "double clicks" on cells A1, B1, C1, D1, or E1.

If the user "double clicks" on cell D1, I want to sort by column D using following custom list: AA1, AA2, AA3, A1, A2, A3, ZZ1, ZZ2, ZZ3, Z1, Z2, Z3. If the user "double clicks" on cell E1, I want to sort by column E using following custom list: AAA+, AAA, AAA-, AA+, AA, AA-, A+, A, A-, ZZZ+, ZZZ, ZZ+, ZZ-, Z+, Z, Z-

The issue I seem to be encountering is that I can’t use more than one custom list (e.g., if I use the column D sort list for column D, column E is also using the same list). I can’t seem to apply individual lists to each column. Would I need to “hardcode” the lists in my macro?

View 5 Replies View Related

Leading Spaces Causing Sort

Jan 30, 2010

I am trying to sort a database with about 500,000 names. For some reason, about half my data has leading spaces and half do not. I have taken a screenshot at the divide so you can see what I mean. The sort in the picture is in this order:

Column D
Column C
Column A

Is there any way to mass purge these leading spaces in Column D (column b also has the issue but the fix is not nearly as important as for column D)?

View 2 Replies View Related

Sort Command - Custom Order Or Sort Ascending Or Descending

Oct 8, 2006

Is it possible to make excel sort ascending or descending but from mid way through alphabet and then loop through the alphabet again. for example. If Cell A1 had "A" in, it would sort as normal.

Cell A1 = A
Cell A2 = B
Cell A3 = C
Cell A4 = D
Cell A5 = E

If Cell A1 had "C" in, it would sort from "C" through the alphabet and then loop to the start of the alphabet as shown below.

Cell A1 = C
Cell A2 = D
Cell A3 = E
Cell A4 = A
Cell A5 = B

View 4 Replies View Related

Sort Worksheets Using Custom Sort To Choose Certain Word?

May 30, 2012

As of right now these are the steps i do to sort...i click custom sort choose My data has headers and then i select from the drop down list the word FRNAME.

is there any way i can setup a macro to do this for me? i tried recording the macro but it just is recording me choosing the column FRNAME is in. This does not work for me since FRNAME end up being in different columns all the time but will always be in row 1.

View 1 Replies View Related

Excel Crash When Run Loop

Jun 3, 2012

I have problems with my excel crashing all the time when I try to run my code. It seems to happen in a loop where I open a .txt file and pull data from it, then close it, and open the next one...

There are no error code, just a message that Excel has stopped working and it will be closed, and then it is forced to restart. Just a mess!

This is my loop code:

Code:
Option Explicit
Dim Desktop As String
Sub Open60only()
Desktop = CreateObject("WScript.Shell").SpecialFolders("Desktop") & Application.PathSeparator
Dim which_folder As String, which_file As String, which_string As String, tick As String
Dim lastrow As Long
Dim wb1 As Workbook, wb2 As Workbook

[code].....

View 9 Replies View Related

Intermittent Crash When Running Macro

Apr 9, 2008

I have having alot of frustation with a big group of Macro's I have written,
all the macros work and run fine most of the time but they crash Excel on occasion and the only way I have been able to fix it is to go into Visual Basic and opening the project up (it is password protected) but not making any changes, after doing this it seems to magically stop crashing, for a while, then doing it again.

I can't work out how or why that would make a difference,
I dont expect you to try and work out a problem in the code or anything like that cause it is too big and would be unreasonable of me to ask,

What I would like to know is if anyone else is aware of this sort of issue, why it happens and if there is any good cure for it?

I am running excel 2003 if that also makes any difference.

View 5 Replies View Related

Excel 2003 :: Force Enable Macros - Crash / Need Toclose

Mar 13, 2012

I have been using Erik's fantastic "Force Enable Macros" code (exactly as it appears)...

force enable macros & ASK to save changes (SOLUTION)

...with the desired results (and comfort) under Excel 2003.

The code works under Excel 2007. However, if there is another workbook open at the sametime (regardless of whether Workbook two has macros or not), I get an Excel "crash";

Code:
Microsoft Office Excel has encountered a problem and needs to close.

[ ] Recover my work and restart Microsoft Excel There is also a Event ID 7001 in the Event Viewer. I have run Excel diagnostics and there are no issues.

View 8 Replies View Related

Bug - Macro Crashes When Run, Doesn't Crash If Save First

Feb 10, 2006

I'm just wondering if any of you can lend some help on a bug i'm encountering. When I press a button on my worksheet to call a macro that brings up a userform, the excel will crash, and give that "do you want to report this error", close down excel, and reopen on a blank worksheet. Strange thing is, this error is avoided if I save the workbook upon opening it, and then call that macro.

The workbook does not read data from external sources, so i dont think is that problem.

Has anyone encountered this?

View 9 Replies View Related

Errors - Microsoft Excel Has Stopped Working - Crash In Pivot Table

Jun 10, 2013

I have created several reports containing pivot charts with slicers, pivot tables and data sets. Total file size is around 5MB. Need to do an update in my pivot table Like adding an additional grouping on one of my dimensions. As soon as I start doing so the Microsoft Excel stopped working error message pops up and my file crashes! Removing existing groupings seems for some reason to be impossible as well: nothing happens when I do this. Ahow to solve this without having to rebuild all my reports?

View 1 Replies View Related

Simple Button Suddenly Make Excel Crash On Saving Then Replace With New One And Work?

Mar 26, 2014

So i got a few macros on a worksheet and one of them is simply :

Sub Pr_Removefilter()
ActiveSheet.ShowAllData
End Sub

Ive worked on the excel a couple of times, everything fine. Then it started crashing upon saving (after changes made that had no possible connection to the macro, on another sheet). After a few painfull trials and errors i located the problem to be this macro button. I erased it, created a new one with the EXACT macro and it works. Why?..

View 1 Replies View Related

Excel 2010 :: Crash - Ready Calculate Flashing Taskbar When Closing / Opening Userform

Jan 8, 2014

Excel will hang up as if it's gone into a continuous loop (Although no looping macros are active) when you open or close a user form. The task bar in Excel will flash Ready Calculate. Visual basic reports no code is running but excel either crashes or becomes very unresponsive. I have to exit and reopen excel in order to fix the problem . It also doesn't happen at any one specific point it can vary. I have various VLOOKUPs around the workbook and userforms display the correct information. I use the INDEX formula in the control source of textboxes. I also use the offset formula to make sure DTPICKER displays correctly.

I am using 'Option Explicit' at the start of all my code. I have tried a 3rd party code cleaner. No visual Basic references are MISSING

[URL]

View 9 Replies View Related

How To Do Custom Sort In VBA

May 20, 2014

I am trying to sort a sheet based on the values in a column.

S, SI, M, MI. and it need to be sorted only in this order.

View 2 Replies View Related

Custom Sort Using VBA

Aug 18, 2006

I would like to custom sort a table by ID, the first ID to be shown on top would be the ID the user enters in an inputbox. Below is the code I used but I don’t know why its not working:

Sub CustSort()
Dim MyCount As Integer
MyCount = Application.CustomListCount + 1
MyValue = InputBox("Enter ID")
Application.AddCustomList Array(MyValue)
ActiveSheet.UsedRange.Sort _
Key1:= Range("A1"), _
Order1:=xlAscending, _
Header:=xlYes, _
OrderCustom:=MyCount, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Application.DeleteCustomList MyCount
End Sub

find attached an example, try entering 300000 in the inputbox the custom sort doesn’t work

View 6 Replies View Related

Custom Sort By 2 Fields

Sep 28, 2006

I'm wanting to be able to sort a table of data using a custom list for both the first criteria and the second criteria. I've setup my custom list correctly and it works perfectly for the first criteria, however, with the second criteria Excel just adopts its default sort order.

Is it possible to get it to use the custom list on the second criteria as well? Is there a simple VBA solution to this?

View 4 Replies View Related

Custom Sort Order

Feb 13, 2007

I feel I've searched thoroughly and wasn't able to find the right answer. I've attached a daily report example that needs the "Product" field to be sorted in a particular order. The order should be JEX, Q3791J, YOO5, KLX9, GHT (all similar products need to be grouped together).

Since the report is run daily the number of rows changes daily: one day can have 50 entries and the next 10. Is there a way to dictate the sort order and insert a blank row between each product grouping?

Once the Products have been separated into their groups, how would I sort each grouping by the "Term" column?

View 9 Replies View Related

Excel Sort Macro Error 400

Oct 5, 2007

I have a macro that should be sorting the last column of data, but it gives me an error code of "400". No explanation of the error, just the number.
I have a feeling it is because I have formulas in place to pull the data from other sources, and the associated "#Value!" error is whited out by using the conditional formatting.
Is there a way to have this macro only look at numeric values?

--------BEGIN VBA--------
Sub SortLastColumn()
Dim myRange As Range, myCol As Integer, sortCol As String

Set myRange = ActiveCell.CurrentRegion
myCol = myRange.Columns.Count
sortCol = myRange.Item(1, myCol).Address

myRange.Select
Selection.Sort Key1:=Range(sortCol), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
IgnoreControlCharacters:=True, IgnoreDiacritics:=True

End Sub

View 9 Replies View Related

Add Custom Sort List To VBA Code

Mar 12, 2009

I have a Macro that I have recorded that autosorts several columns for me. This works fine as I have 5 columns that need to be sorted in a particular way.

The problem is that I have a custom list which I stored using the: Tools>Options>Custom List tab. Now this works fine on my pc as I have the custom list stored on my PC.however the problem is when someone else uses it on their PC it may no longer work as they won't have my custom list stored on their PCs.

Is there a way to store the custom list in a Macro and then use that list to sort to the criteria needed. For example "One, Two, Three, Four" will not store in alphabetically, so hope would I be able to sort so that they would appear in a chronological manner? Below is the code for the Macro I recorded. As you can see one of the lines says "OrderCustom:=6"; this I am assuming is reading from the list I created.

View 2 Replies View Related

Custom Sort Multiple Sheets?

Nov 23, 2011

I have found many macros for sorting multiple sheets by a single column in Excel, however, need macro for sorting multiple sheets by column "A", then column "B".

View 1 Replies View Related

How To Create Custom Sort List

Aug 25, 2013

I am trying to create a custom sort list by going to preferences/custom lists and typing 37 items into a new list in Excel. It will not take all of the items after I type them in. Is there a limit as to how many items can be in the list. It seems to only take 18-20 items out of the 37 and erases the rest.

View 9 Replies View Related

Custom List To Sort Data

May 28, 2014

I am having trouble finding info on this. I am trying to create a custom list to sort data.

I only want to sort two of the letters in my first Level or Column. For instance I want to sort Column A Alphabeticaly as A, B, C, D, but once I get to E, have the rest of the list in a random order that is sorted by my next level. Is there a wildcard character that can be used to have my next sorting level take over once I get to E?

View 4 Replies View Related

Create A Custom Sort Order

May 13, 2009

I am trying to create custom sort list. It works below when I define range as A1:A79.

Sub SortWS2()
Dim SortOrder As Variant
Dim sheetsorder As Range
Dim Ndx As Long
Application. ScreenUpdating = False
With Worksheets("Sort Order").Range("A1:A79")
For Ndx = .Cells.Count To 1 Step -1
Worksheets(.Cells(Ndx).Value).Move before:=Worksheets(1)
Next Ndx
End With
Application.ScreenUpdating = True
End Sub

I have created a dynamic range called sheetsorder. If I revise my code it does not work.

Sub SortWS2()................

View 6 Replies View Related







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