VBA 400 Error On Macro

Oct 13, 2011

I have a macro (see code below) that goes down a range of data and merges duplicate cell values for me. However, sometimes when I run the macro, I'm getting the dreaded pop up that says Visual Basic with a big red X and "400".

This seems to be an issue of the length of data; if I'm only doing a small amount of rows it will work, but the larger it gets then I get an error. how to edit so I can run it down hundreds of rows of data?

Sub GroupDown()
Dim varData As Variant, varContent As Variant
Dim strMyRange As String
Application.ScreenUpdating = False
Application.DisplayAlerts = False
strMyRange = ActiveCell.Address
varContent = ActiveCell.Value
For Each varData In Selection.Cells

[code]....

View 6 Replies


ADVERTISEMENT

Vba Macro Error: Compile Error Named Argument Not Found

Apr 26, 2006

I have some code that, although works fine in Excel 2003, does not in Excel 1997. I receive this error when I try running it:

COMPILE ERROR:
NAMED ARGUMENT NOT FOUND

Sub HPVAL()
Dim r As Range, myStr As String
myStr = "HP"
Set r = Cells. Find(What:=myStr, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
If Not r Is Nothing Then
r = r.Value
While Not r Is Nothing
Set r = Cells.FindNext(r)
If Not r Is Nothing Then
r = r.Value
End If
Wend
End If
End Sub

It looks like Excel is getting hung up on the "SearchFormat:=" portion of the code.

View 2 Replies View Related

Compile Error Syntax Error In Macro

May 17, 2014

VB:
Selection.FormulaArray = _
"=IF(RC[-7]=""Weekly"",RC[-1],IF((ParentCode=RC[-10])*(ClassType=""Active""),IF((EndDate=EOMONTH(EndDate,0))*(RC[-7]
={""Monthly"",""Quarterly""}),RC[-1],0),IF(RC[-7]=""Daily"",IF(SUMPRODUCT(((ParentCode=RC[-10])*(FundType=""C"")*
(ClassType=""Inactive Class"")*(TermDate<>"""")*(TermDate>=StartDate)*(TermDate<=EndDate))+((ParentCode=RC[-10])*

[Code] .....

I recorded macro for this formula its giving me syntax error i did " _" after the break but its still not working..

View 4 Replies View Related

Macro: Compile Error - Syntax Error

Feb 1, 2010

"Compile error - Syntax Error"

and the following line highlighted in yellow

"Sub CreateWorkbooks()"

It worked on Excel 2000 but not now and dont work either in Excel 2007.

Heres the complete code .....

View 9 Replies View Related

Macro, On Error End Sub

May 1, 2008

Lookup macro that will check a range K5:K150 and if it finds the typed word "Error" it will End Sub

View 9 Replies View Related

Error 424 In Macro

Apr 21, 2009

I am a very basic user in Excel and I piece mealed together a macro that takes a row and copies the values to a new sheet if a cell in that row meets a particular criteria. I then go to delete that row from the original sheet. The row gets deleted but I get an 424 Error.

Sub Sort()
Dim LastRowMain As Long
Dim LastRowNewOrd As Long
Dim i As Long
Application.ScreenUpdating = False
LastRowMain = Worksheets("Lettres").Range("A" & Rows.Count).End(xlUp).Row
With Worksheets("Lettres")
For i = 2 To LastRowMain Step 1
Select Case Cells(i, "M").Value
' This copies Oui to Fermer
Case "Oui"................................

View 9 Replies View Related

VPN Connection Causes Macro Error

Jul 11, 2014

This file connects to a weather API. The laptop I am using connects through a VPN connection. For some reason whenever I am on the VPN if I try to refresh the information I will get an error and the macro will fault out. Other than that the macro works perfectly fine.

Attached is the file in question : Weather Forecast Spreadsheet Draft V12.xlsm‎

When debugging the error goes to:

How can I place in an error management instead of the code just getting blocked out.

View 1 Replies View Related

Macro That Keeps Returning Error?

Feb 27, 2014

This macro keeps returning and error. It does it on all pages, except one. It works perfect on one page. This is a snip of the macro. if more info is needed. Let me knowMacro error.PNG It is supposed to Auto fit will filling in cells.

View 10 Replies View Related

Error Message For Macro

Jan 11, 2009

I have one line of code that I need an error message for:

View 2 Replies View Related

Macro Generates Error '5'

Nov 18, 2009

I have been getting this '5' error a lot lately and I dont know why. Many of my macros have had this error. Run-time error '5': Invalid procedure call or argument. The offending (Highlited in Red)

View 3 Replies View Related

Macro Runtime Error?

Jul 16, 2014

I have a bug on a macro that was working until yesterday. I did not write this macro and I cannot seem to fix it. The debug stops at the below command. The data it looks at seems to be in the right format so I think there is something else that is wrong.

Set PTCache = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:=PRange)

View 3 Replies View Related

Macro Run Time Error 91

Jul 23, 2007

Sub asdf()
Dim c As Range
Dim x As Long
Dim y As Integer

Set c = Columns("A:B"). Find(" Total", lookat:=xlWhole)
x = c.Row
For y = 15 To 4 Step -1
If Cells(x, y) = 0 Then Columns(y).Delete
Next y
End Sub
However, it errors out at
x = c.Row
Saying "object variable or With block variable not set"
I have xl2000. Could this be the problem?

With the code I'm trying to locate my "Total" row. Then delete all columns from D:O with a value of zero. An example sheet is supplied at the link.

View 9 Replies View Related

Macro But It Comes Up With A Subscript Error

Dec 29, 2007

Re my last I have tried this macro but it comes up with a subscript error.

Private Sub Workbook_Open()
Sheets("Sheet1").Visible = xlVeryHidden
UserForm5.Show
End Sub

The sheet name is Sheet1(Main Data Entry) and the Workbook is called 'This Workbook".

View 9 Replies View Related

Macro Runtime Error 9

Dec 7, 2007

I downloaded an excel file from a German student's site. With this file, it is possible to calculate very simply species turnover (I'm a biologist) activating a macro. When I run it, afetr answering lots of questions (which I think I answer well), it appears an "error run-time 9 - subscript out of range". In the download folder there were only two files: turnover.xls and instructions.pdf
Here is the code. The debug highlights the bold line.
.............................................

View 9 Replies View Related

Macro Cannot Be Found Or Is Disabled Error

Mar 7, 2013

I have a worksheet with several option buttons and until yesterday, I had no problem selecting them. But today, every time, I select a radio button, an error shows up stating "Cannot run Macro "Option Button_click. Macro is not available in this workbook or is disabled". When the user selects a radio button, text appears in Col B depending on what button was selected (using VLOOKUP). That stuff is still working fine. It's just as soon as I click a radio button, the error shows up.

Based on the radio button selected, user can add in information to the columns adjacent to it, and then click a button to store that information in some rows below. The code for that button is stored in the sheet module. I have tried enabling macros and disabling macros and no change has appeared. What I have noticed though is that yesterday, when i opened the workbook, a yellow bar appeared asking if I wanted to "Enable Content". Today, that bar didn't appear.

View 1 Replies View Related

On Error, Go Back A Step In Macro

Oct 7, 2008

I have a macro in one file which uses an input box where the user types in a subcontractor code to retrieve address and contact details from another file.

If the user inputs the incorrect subcontractor code, an error message box pops up. Currently the user then has to select a button in the original file to restart the macro at the input box stage.

What I want to happen is when ok is selected on the error message, to return to the input box so in my macro below where the error message says "An error occurred - you asked for a subcontractor that does not exist. Please try again." and the user selects OK, I would like it to return to the 'Enter the Subcontractor line and the "Please enter the Subcontractor code" input box reappears.

View 8 Replies View Related

Macro Quits Working After Any Error

Nov 3, 2009

I cant seem to figure out why the macro in this workbook quits working after any error.

I can Break from the error but then the macro ceases to function at all. I am forced to close the workbook and re-open it.

FYI
This macro writes to the registry. Simple text values only.
Example: Retrieving data. Its currently generic in format.
"sLogin" is a user entered name
"TargetValue" is a selected cell value (activecell).

View 2 Replies View Related

Spacing Error With Email Macro

Dec 19, 2009

The email macro I set up didn't work when I referenced the sendto from a cell in sheet 2; I changed it to reference an email address on sheet 1 and it worked with spacing errors. I need to fix the spacing errors, and I need to be able to pull the email from sheet 2. Code referencing sheet 2:

View 3 Replies View Related

Macro Error After Protect File

Jan 4, 2010

I created excel form with calculated formula and macro. Everything worked fine. To protect spreadsheet formula I protected file. But after protection when I ran file I get macro error message. Then I remove protection become work without error messgae. How to fix that problem?

View 6 Replies View Related

ERROR While Running Macro From Template

Feb 2, 2010

This code works well when I run it saved as an .xls. When I save the file as a template and then try to run it bombs on the very last line.

View 2 Replies View Related

Error 1004 :: If Run A Macro On Other Files

Feb 3, 2010

I'm getting error 1004 for some files and i'm not able to figure out what the issue is.

I need to find out what is causing the error. I have attached the macro
(MergeFiles_v2.xls ) and 3 files ( Migration_Request.Xls, Migration_Request1.Xls & Migration_Request2.Xls ).

if i run the macro for any file other than Migration_Request1.Xls , i get the error.

View 2 Replies View Related

Error When Put Macro Into Toggle Button

Nov 4, 2011

ToggleButton? I have made this Macro work

Sub group()
'
Dim i As Integer

Sheets("Operating Income Trending (LOC)").Select
For i = 53 To 2 Step -1
If Cells(7, i) = "" Then
Sheets("Operating Income Trending (LOC)").Columns(i).EntireColumn.Hidden = True

End If
Next i
End Sub

And when i tried to put it into a togglebutton like below:

Private Sub ToggleButton1_Click()
Select Case ToggleButton1.Caption
Case "Group"

Dim i As Integer

Sheets("Operating Income Trending (LOC)").Select

[Code] .........

Then instead of hiding all the blank columns, it hides almost all the columns, leaving some that are supposed to hide. i could not figure out why as it worked fine as individual macro.

View 2 Replies View Related

Checkdate Error When Running Macro

Oct 3, 2012

I have a code to save a file. I've used it before so tried to adapt for current requirements. Seems I can't get around the "checkdate" as I get a "Compile Error: Sub or Function not defined" message.

Sub SavetoEst()
Dim strHeader As String
Dim i As Integer, j As Integer, k As Integer, l As Integer, m As Integer, n As Integer, x As Integer
Dim fs0
Dim f, getname, path
Dim fd As FileDialog
Dim fdfil As FileDialogFilters
Dim strFIlename As String
Dim strdate As String

[code]....

View 2 Replies View Related

Macro To Edit Error Bars?

Oct 29, 2012

how to control either the X or Y axis error bars for a scatter chart.

I'm building something like a gantt chart and I only want to use the X axis error bars and delete the Y axis bars. I've been able to add error bars by using "ActiveChart.SeriesCollection(1).HasErrorBars = True" but when i select the error bars using "ActiveChart.SeriesCollection(1).ErrorBars.Select" the Y axis (Vertical Error Bars) are automatically selected and any formatting I apply is added to the Y axis and left off of the X axis.

Does anyone know how to delete the Y axis error bars and/or choose only the X axis error bars?

View 5 Replies View Related

Sorting Table - Macro Error

Jan 5, 2013

Created the following macro, but doesn't seem to work.

Sub SortTable()
With Range("TC_Table")
.Sort key1:=Range("TC_Table").Cells(1, 1), Order1:=xlAscending
.Sort key2:=Range("TC_Table").Cells(1, 2), Order2:=xlAscending
.Header = xlYes

[Code] .....

View 7 Replies View Related

Error When Using Subtotal Function In Macro

Jan 14, 2013

I am trying to create a macro which will use the subtotal function to do a count on all the the new loans in column A. The could below is what I have tried but I am getting a run-time error 13 "Type Mismatch" error at the line highlighted in red in the code. How to write the Subtotal function in the macro.

Code:
Sub CountNewLoans()

Dim cnlFinalRow As Integer
Dim cnlRow As Integer

Dim x As String
Dim y As String

[Code] ......

View 6 Replies View Related

Using Find In Macro Without Error If Nothing Found?

Feb 12, 2013

I'm trying to write some VBA which will allow me to find certain instances of data across a number of different sheets and copy this into another sheet.

However if the sheet doesn't contain the data I'm searching for an error pops up and the macro dies, is there a way to search where if the macro doesn't find anything it skips to the next line?

View 1 Replies View Related

Macro Fill Down Syntax Error?

May 17, 2013

I am having some issues with my macro. I keep getting a syntax error? I am trying to combine these coding combinations together. Code G0398 with 95800, code G0398 with 95801 so on so fourth..

G0398
95800

G0399
95801

G0400
95805

[Code] ...........

View 2 Replies View Related

VBA Macro Throwing Compile Error

Dec 3, 2013

Basically I want the macro to look through a column of values and if any cell in that column has the value 'LOCK' the macro would hardcode 'n' into the adjacent cell. Additionally, because the column in which the LOCK cells would appear is part of a vlookup, it returns #N/A which I would like my macro to ignore and then continue to evaluate the next cell all the way to the end of the column.

The code is the following:

Sub Hard_Code_Cells()

On Error Resume Next

lastrow = Cells.Find(What:="*", After:=Range("A1"), LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

[Code] .......

I've been receiving the error message 400 when I trigger the macro and I'm not sure how to correct my code to resolve the issue.

View 8 Replies View Related

Column Compare Macro Error

Jul 12, 2014

I've created a macro that will compare 2 columns and move the rows around (whilst maintaining the original order) to line matches up and leave spaces for mismatches. In the file attached if you run the macro "RouteCompare" on the "Selection1" tab it works fine as there is only a small number of rows.

When i try it on "Selection2" tab with over 2K rows it bombs out. IT seems to only work for columns that are only slightly mismatched or not that long.

I'm not an expert on it, but i thought it might be excel using up all the resorces it has and grinding to a halt.

Is there any way to edit the macro to allow reset whatever is slowing it wodn after a period of time, or changing the macro to prevent it from crashing on long flows?

Here is the code I'm using:

Sub CompareMyRoute()
'Macro to compare flows
'Created by by Brendan M Murphy
Application.ScreenUpdating = False

[Code ...........

View 5 Replies View Related







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