This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Wrong number of arguments (Error 450)

  • 7 contributors

The number of arguments to a procedure must match the number of parameters in the procedure's definition. This error has the following causes and solutions:

The number of arguments in the call to the procedure wasn't the same as the number of required arguments expected by the procedure. Check the argument list in the call against the procedure declaration or definition.

You specified an index for a control that isn't part of a control array .

The index specification is interpreted as an argument but neither an index nor an argument is expected, so the error occurs. Remove the index specification, or follow the procedure for creating a control array. Set the Index property to a nonzero value in the control's property sheet or property window at design time .

You tried to assign a value to a read-only property , or you tried to assign a value to a property for which no Property Let procedure exists.

Assigning a value to a property is the same as passing the value as an argument to the object's Property Let procedure. Properly define the Property Let procedure; it must have one more argument than the corresponding Property Get procedure. If the property is meant to be read-only, you can't assign a value to it.

For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.

Was this page helpful?

Additional resources

wrong number of arguments or invalid property assignment 'string'

Excel Top Contributors: HansV MVP  -  Andreas Killer  -  Ashish Mathur  -  Jim_ Gordon  -  Jeovany CV  ✅

November 12, 2024

Excel Top Contributors:

HansV MVP  -  Andreas Killer  -  Ashish Mathur  -  Jim_ Gordon  -  Jeovany CV  ✅

  • Search the community and support articles
  • Microsoft 365 and Office
  • Search Community member

Ask a new question

Split Function Error. i get and error while trying to run the following code. "Compile Error Wrong Number of Arguments or Invalid property assignment".

I have tried using code from other coders from internet but everytime i get the same error.

Compile Error

Wrong Number of Arguments or Invalid property assignment

Sub Split()

Dim TextString As String, WArray() As String, Counter As Integer, Strg As String

TextString = Range("A2").Value

WArray = Split(TextString, "_")

For Counter = LBound(WArray) To UBound(WArray)

Strg = WArray(Counter)

Cells(2, Counter + 1).Value = Trim(Strg)

Next Counter

Report abuse

Reported content has been submitted​

HansV MVP

This is because you have named the macro Split. This conflicts with the Split function. Rename the macro, for example to SplitText.

Also, you're missing the line

just above End Sub.

3 people found this reply helpful

Was this reply helpful? Yes No

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

Thanks for your feedback.

Replies (2) 

Question info.

  • Norsk Bokmål
  • Ελληνικά
  • Русский
  • עברית
  • العربية
  • ไทย
  • 한국어
  • 中文(简体)
  • 中文(繁體)
  • 日本語

Excel Help Forum

  • Forgotten Your Password?

Username

  • Mark Forums Read
  • Quick Links :
  • What's New?
  • Members List

Forum Rules

  • Commercial Services
  • Advanced Search

Home

  • Microsoft Office Application Help - Excel Help forum
  • Excel Programming / VBA / Macros
  • [SOLVED] wrong number of arguments or invalid property assignment

wrong number of arguments or invalid property assignment

Thread tools.

  • Show Printable Version
  • Subscribe to this Thread…

Rate This Thread

  • Current Rating
  • ‎ Excellent
  • ‎ Average
  • ‎ Terrible

wrong number of arguments or invalid property assignment 'string'

I've been racking my brain on this for a while now and trying different things but can't for the life of me figure out why I'm getting an error. I'm getting the error "wrong number of arguments or invalid property assignment" after the first Else statement, so on the line: ActiveWorkbook.Worksheets(sht).Range.AutoFilter Field:=Column1, Criteria1:= _ ">=" & Threshold1, Operator:=xlAnd Any ideas as to why? Please Login or Register to view this content. new Clipboard(".copy2clipboard",{target:function(a){for(;a ? a.getAttribute?a.getAttribute?!/bbcode_description/.test(a.getAttribute("class")):null:null:null;)a=a.parentNode;for(var b=a.nextElementSibling;b?!b.classList.contains("bbcode_code"):null;)b=b.nextElementSibling;return b}});

Marc L is offline

Re: wrong number of arguments or invalid property assignment

Try first to replace Sheets with Worksheets in the For codeline …
Here's the questionable section with the code that throws the error in bold: Please Login or Register to view this content. new Clipboard(".copy2clipboard",{target:function(a){for(;a ? a.getAttribute?a.getAttribute?!/bbcode_description/.test(a.getAttribute("class")):null:null:null;)a=a.parentNode;for(var b=a.nextElementSibling;b?!b.classList.contains("bbcode_code"):null;)b=b.nextElementSibling;return b}});
Originally Posted by Marc L Try first to replace Sheets with Worksheets in the For codeline … I tried that, I'm still getting the same error?

TMS is offline

Compare "<=" & Threshold1, Operator:=xlAnd Else ActiveWorkbook.Worksheets(sht).Range.AutoFilter Field:=Column1, Criteria1:= _ ">=" & Threshold1, Operator:=xlAnd End If To: "<=Threshold2", Operator:=xlAnd Else ActiveWorkbook.Worksheets(sht).Range.AutoFilter Field:=Column2, Criteria1:= _ ">=Threshold2", Operator:=xlAnd Etc.
Trevor Shuttleworth - Retired Excel/VBA Consultant I dream of a better world where chickens can cross the road without having their motives questioned 'Being unapologetic means never having to say you're sorry' John Cooper Clarke
Originally Posted by TMS Compare "<=" & Threshold1, Operator:=xlAnd Else ActiveWorkbook.Worksheets(sht).Range.AutoFilter Field:=Column1, Criteria1:= _ ">=" & Threshold1, Operator:=xlAnd End If To: "<=Threshold2", Operator:=xlAnd Else ActiveWorkbook.Worksheets(sht).Range.AutoFilter Field:=Column2, Criteria1:= _ ">=Threshold2", Operator:=xlAnd Etc. Yes I realized that for the rest of them the syntax was off. I changed those to match the syntax of the Factor1 etc... "If" statements (how you first said compare) but still get the error
Add ActiveWorkbook where you forgot it or remove it if not necessary …
Originally Posted by Marc L Add ActiveWorkbook where you forgot it or remove it if not necessary … I'm not sure what you mean? I don't know where I would have forgotten it, I tried to include it everywhere, and when I try removing it I still get an error :/
Inconstant code, like Sheets & Worksheets, why some sheets references are alone and why others use ActiveWorkbook before ? Do it manually with Excel features and once that works, go back to the previous state, activate the Macro Recorder and redo the same manual operations in order you can compare the working generated code with yours …
Ok I finally figured it out. Apparently since the data is in a table, in order to reference the table I needed to add "ListObjects(1)" after the Wrosksheets reference. So it becomes ActiveWorkbook.Worksheets(sht) .ListObjects(1) .Range.AutoFilter Field:=Column2, Criteria1:= _ ">=Threshold2", Operator:=xlAnd

Similar Threads

Wrong number of arguments or invalid property assignment vb6, [solved] wrong number of arguments invalid or property assignment error, compile error: wrong number of arguments or invalid property assignment .... help, wrong number of arguments invalid or property assignment error, [solved] wrong number of arguments or invalid property assignment, [solved] wrong number of arguments or invalid property assignment, wrong number of arguments or invalid property assignment, posting permissions.

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  • BB code is On
  • Smilies are On
  • [IMG] code is Off
  • HTML code is Off
  • Trackbacks are Off
  • Pingbacks are Off
  • Refbacks are Off
  • ExcelForum.com

MrExcel Message Board

  • Search forums
  • Board Rules

Follow along with the video below to see how to install our site as a web app on your home screen.

Note: This feature may not be available in some browsers.

  • If you would like to post, please check out the MrExcel Message Board FAQ and register here . If you forgot your password, you can reset your password .
  • Question Forums
  • Excel Questions

Error in VBA(wrong number of arguments or invalid property assignment)

  • Thread starter Thread starter JiangSH
  • Start date Start date Dec 13, 2021
  • Tags Tags debug error error vba
  • Dec 13, 2021

hi everyone! I was doing some exercise about Function in VBA when an error occurred(wrong number of arguments or invalid property assignment).Here is the picture. Really needs your help !! thx!!  

Attachments

Screenshot 2021-12-14 121349.png

Excel Facts

Well-known member.

  • Dec 14, 2021

stackoverflow.com

What is the easiest way to take two columns of data and convert to dictionary?

stackoverflow.com

MrExcel MVP, Moderator

Welcome to the MrExcel board! When asking questions about a particular code please post the actual code, not a picture of it. My signature block below has more help on how to do that. Also, if asking about an error, as well as giving the error message, tell us which line of code caused the error.  

A bit troublesome since code is short ? . I'm just guessing your problem here. This is not way to add data to Dictionary The Dict(KeyColumn(i, 1)) = ValueColumn(i, 1) should be Dict.Add KeyColumn(i, 1), ValueColumn(i, 1) However, your column has no range limit. When KeyColumn(i, 1) becomes rows of zero or blank, then you will have error.  

Zot said: This is not way to add data to Dictionary The Dict(KeyColumn(i, 1)) = ValueColumn(i, 1) Click to expand...
Peter_SSs said: Dict(SomeKeyValue) = SomeItemValue .. is a perfectly valid way to add an entry to a Dictionary. One thing that I noticed about the code is that "Key" and "Value" are used as variable arguments for the function and it is a very bad idea to use words as variables that vba already has special meanings for. There could also be an issue with the type of double quote marks used. Click to expand...
Zot said: Here is what I converted Click to expand...

It is not entirely clear what the OP is wanting to achieve, but this is my estimate. VBA Code: Sub test1() Dim dictl As Variant dictl = CreateDictForTwoColumns("a", "b") End Sub Function CreateDictForTwoColumns(sKey As String, sValue As String) Dim KeyColumn As Variant, ValueColumn As Variant Dim Dict As Object Dim i As Long Set Dict = CreateObject("scripting.dictionary") KeyColumn = ThisWorkbook.Worksheets(1).Range(sKey + ":" + sKey) ValueColumn = ThisWorkbook.Worksheets(1).Range(sValue + ":" + sValue) For i = 1 To UBound(KeyColumn, 1) Dict(KeyColumn(i, 1)) = ValueColumn(i, 1) Next CreateDictForTwoColumns = Array(Dict.Keys, Dict.Items) End Function  

Peter_SSs said: It is not entirely clear what the OP is wanting to achieve, but this is my estimate. VBA Code: Sub test1() Dim dictl As Variant dictl = CreateDictForTwoColumns("a", "b") End Sub Function CreateDictForTwoColumns(sKey As String, sValue As String) Dim KeyColumn As Variant, ValueColumn As Variant Dim Dict As Object Dim i As Long Set Dict = CreateObject("scripting.dictionary") KeyColumn = ThisWorkbook.Worksheets(1).Range(sKey + ":" + sKey) ValueColumn = ThisWorkbook.Worksheets(1).Range(sValue + ":" + sValue) For i = 1 To UBound(KeyColumn, 1) Dict(KeyColumn(i, 1)) = ValueColumn(i, 1) Next CreateDictForTwoColumns = Array(Dict.Keys, Dict.Items) End Function Click to expand...
Peter_SSs said: Welcome to the MrExcel board! When asking questions about a particular code please post the actual code, not a picture of it. My signature block below has more help on how to do that. Also, if asking about an error, as well as giving the error message, tell us which line of code caused the error. Click to expand...

Similar threads

KlausW

  • Question Question
  • Mar 12, 2024
  • Patriot2879
  • Jun 18, 2024
  • Apr 10, 2024
  • Oct 19, 2024
  • Sep 11, 2024

Forum statistics

Share this page.

wrong number of arguments or invalid property assignment 'string'

We've detected that you are using an adblocker.

Which adblocker are you using.

AdBlock

Disable AdBlock

wrong number of arguments or invalid property assignment 'string'

Disable AdBlock Plus

wrong number of arguments or invalid property assignment 'string'

Disable uBlock Origin

wrong number of arguments or invalid property assignment 'string'

Disable uBlock

wrong number of arguments or invalid property assignment 'string'

COMMENTS

  1. VBA Wrong number of arguments or invalid property assignment

    Out of touch with vba and so i am sure its a silly mistake somewhere. Would be really helpful if someone could point that out. Code: Private Function generate() As Integer Dim source_size As Long Dim target_size As Long Dim i As Long Dim j As Long Dim count As Long Dim source1 As Range Dim target1 As Range Set source1 = Worksheets("Filter").Range(C4, C6498) Set target1 = Worksheets("30").Range ...

  2. Wrong number of arguments (Error 450)

    Assigning a value to a property is the same as passing the value as an argument to the object's Property Let procedure. Properly define the Property Let procedure; it must have one more argument than the corresponding Property Get procedure. If the property is meant to be read-only, you can't assign a value to it.

  3. I am getting a compile error: Wrong number of arguments or invalid

    Add this to the top of your code and it will work. Sourcewb is a variable that you created and needs to be declared and also assigned. Dim Sourcewb As Workbook. Set Sourcewb = ActiveWorkbook. AD. adamhein. Replied on August 25, 2018. Report abuse. In reply to JasleS's post on August 25, 2018.

  4. Split Function Error. i get and error while trying to run the

    Wrong Number of Arguments or Invalid property assignment. Sub Split() Dim TextString As String, WArray() As String, Counter As Integer, Strg As String . TextString = Range("A2").Value . WArray = Split(TextString, "_") For Counter = LBound(WArray) To UBound(WArray) Strg = WArray(Counter) Cells(2, Counter + 1).Value = Trim(Strg) Next Counter. End Sub

  5. VBA Error wrong number of arguments or invalid property assignment

    Sub MailReports() Dim rng As Range Dim OutApp As Object Dim OutMail As Object Dim rngAttach As Range Dim hlink As String 'Set range for file attachment, cell should contain the path and file name With ActiveSheet Set rngAttach = .Range("b5") End With Set rng = Nothing ' Only send the visible cells in the selection.

  6. 800A01C2

    I got this error: 800A01C2 - Wrong number of arguments or invalid property assignment. at line 4 in VBScript code. Here is my test.vbs code: Set WshShell = CreateObject("WScript.Shell") strInput = InputBox("Please enter the date (yyyymmdd)", "Enter Date") set strInput = WScript.Arguments. WshShell.Run "mybatch.bat" & strInput, 0.

  7. Compile Error: Wrong number of arguments or invalid property assignment

    Easiest way to fix is to jump over to late binding by changing the way your olApp/Mail are declared and newed. Try changing to this: "Wrong number of arguments" means you are calling a subroutine with a different number of arguments (a.k.a. parameters) than the subroutine allows.

  8. wrong number of arguments or invalid property assignment

    Re: wrong number of arguments or invalid property assignment Ok I finally figured it out. Apparently since the data is in a table, in order to reference the table I needed to add "ListObjects(1)" after the Wrosksheets reference.

  9. Debug wrong number of arguments or invalid property assignment error

    The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

  10. Error in VBA(wrong number of arguments or invalid property assignment

    This is not way to add data to Dictionary. The Dict (KeyColumn (i, 1)) = ValueColumn (i, 1) Click to expand... Dict (SomeKeyValue) = SomeItemValue. .. is a perfectly valid way to add an entry to a Dictionary. One thing that I noticed about the code is that "Key" and "Value" are used as variable arguments for the function and it is a very bad ...