ByRef Argumenttype mismatch when passing an array to a sub or function2019 Community Moderator ElectionHow to pass an array to a function in VBA?ByRef argument type mismatch error on Join()Arguments passed to a function change in value after the function returns to the calling subVBA how to pass an array to a functionVBA byref argument type mismatch when calling a function from a function being calledPassing Variant ByRef in VBA Excel 2007String Array value can not pass through functionExcel VBA pass object ByRef never sems to workVBA ByRef Argument Type Mismatch string into stringVBA ByRef argument type mismatchcompile error: ByRef argument type mismatch, What am I missing?

How to secure an aircraft at a transient parking space?

'The literal of type int is out of range' con número enteros pequeños (2 dígitos)

Why does a recursive function stop on random numbers?

Reversed Sudoku

Can Mathematica be used to create an Artistic 3D extrusion from a 2D image and wrap a line pattern around it?

Why does liquid water form when we exhale on a mirror?

Was Luke Skywalker the leader of the Rebel forces on Hoth?

Counting all the hearts

How do I express some one as a black person?

How to detect if C code (which needs 'extern C') is compiled in C++

Doesn't allowing a user mode program to access kernel space memory and execute the IN and OUT instructions defeat the purpose of having CPU modes?

Shifting between bemols (flats) and diesis (sharps)in the key signature

Why would one plane in this picture not have gear down yet?

Should I tell my boss the work he did was worthless

Database Backup for data and log files

Rewrite the power sum in terms of convolution

Conservation of Mass and Energy

Can I pump my MTB tire to max (55 psi / 380 kPa) without the tube inside bursting?

Is "conspicuously missing" or "conspicuously" the subject of this sentence?

What are some noteworthy "mic-drop" moments in math?

What's the "normal" opposite of flautando?

Do I really need to have a scientific explanation for my premise?

Does "Until when" sound natural for native speakers?

Examples of a statistic that is not independent of sample's distribution?



ByRef Argumenttype mismatch when passing an array to a sub or function



2019 Community Moderator ElectionHow to pass an array to a function in VBA?ByRef argument type mismatch error on Join()Arguments passed to a function change in value after the function returns to the calling subVBA how to pass an array to a functionVBA byref argument type mismatch when calling a function from a function being calledPassing Variant ByRef in VBA Excel 2007String Array value can not pass through functionExcel VBA pass object ByRef never sems to workVBA ByRef Argument Type Mismatch string into stringVBA ByRef argument type mismatchcompile error: ByRef argument type mismatch, What am I missing?










1















I am working on a little project for work. All I am trying to do is create an array in Sub1 and call a function, pass the array to that function and have it fill the array.



Very simplified, it looks something like this:



Private Sub whatever()
Dim arr(10, 2) As String
workArray arr
End Sub

Sub workArray(ByRef arr As String)
'- do stuff here
End Sub


I have googled so much and just can't figure out what I'm doing wrong. I have also tried:



  • call workArray(arr)

  • call workArray arr

  • workArray(arr)

  • workArray arr

I've read that I can only pass an array ByRef, so I am sure that should be alright. The array arr is of type String, the array the function expects is declared as String - that should be alright too. I always get "ByRef argument type mismatch". Is the problem maybe with the type of String? Are String-arrays behaving differently?



Anyone in here kind enough to release me of my pain?










share|improve this question
























  • Possible duplicate of How to pass an array to a function in VBA?

    – Mr.Burns
    Mar 6 at 15:39















1















I am working on a little project for work. All I am trying to do is create an array in Sub1 and call a function, pass the array to that function and have it fill the array.



Very simplified, it looks something like this:



Private Sub whatever()
Dim arr(10, 2) As String
workArray arr
End Sub

Sub workArray(ByRef arr As String)
'- do stuff here
End Sub


I have googled so much and just can't figure out what I'm doing wrong. I have also tried:



  • call workArray(arr)

  • call workArray arr

  • workArray(arr)

  • workArray arr

I've read that I can only pass an array ByRef, so I am sure that should be alright. The array arr is of type String, the array the function expects is declared as String - that should be alright too. I always get "ByRef argument type mismatch". Is the problem maybe with the type of String? Are String-arrays behaving differently?



Anyone in here kind enough to release me of my pain?










share|improve this question
























  • Possible duplicate of How to pass an array to a function in VBA?

    – Mr.Burns
    Mar 6 at 15:39













1












1








1








I am working on a little project for work. All I am trying to do is create an array in Sub1 and call a function, pass the array to that function and have it fill the array.



Very simplified, it looks something like this:



Private Sub whatever()
Dim arr(10, 2) As String
workArray arr
End Sub

Sub workArray(ByRef arr As String)
'- do stuff here
End Sub


I have googled so much and just can't figure out what I'm doing wrong. I have also tried:



  • call workArray(arr)

  • call workArray arr

  • workArray(arr)

  • workArray arr

I've read that I can only pass an array ByRef, so I am sure that should be alright. The array arr is of type String, the array the function expects is declared as String - that should be alright too. I always get "ByRef argument type mismatch". Is the problem maybe with the type of String? Are String-arrays behaving differently?



Anyone in here kind enough to release me of my pain?










share|improve this question
















I am working on a little project for work. All I am trying to do is create an array in Sub1 and call a function, pass the array to that function and have it fill the array.



Very simplified, it looks something like this:



Private Sub whatever()
Dim arr(10, 2) As String
workArray arr
End Sub

Sub workArray(ByRef arr As String)
'- do stuff here
End Sub


I have googled so much and just can't figure out what I'm doing wrong. I have also tried:



  • call workArray(arr)

  • call workArray arr

  • workArray(arr)

  • workArray arr

I've read that I can only pass an array ByRef, so I am sure that should be alright. The array arr is of type String, the array the function expects is declared as String - that should be alright too. I always get "ByRef argument type mismatch". Is the problem maybe with the type of String? Are String-arrays behaving differently?



Anyone in here kind enough to release me of my pain?







arrays excel vba string byref






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 7:54









Pᴇʜ

23.8k62952




23.8k62952










asked Mar 6 at 15:27









McMuellermilchMcMuellermilch

87




87












  • Possible duplicate of How to pass an array to a function in VBA?

    – Mr.Burns
    Mar 6 at 15:39

















  • Possible duplicate of How to pass an array to a function in VBA?

    – Mr.Burns
    Mar 6 at 15:39
















Possible duplicate of How to pass an array to a function in VBA?

– Mr.Burns
Mar 6 at 15:39





Possible duplicate of How to pass an array to a function in VBA?

– Mr.Burns
Mar 6 at 15:39












1 Answer
1






active

oldest

votes


















0














You are missing () in the function, an array needs () after the variable when passing it somewhere else so VBA knows it as an array



Private Sub whatever()
Dim arr(10, 2) As String
workArray arr
End Sub

Sub workArray(ByRef arr() As String)
'- do stuff here
End Sub


Edit



I look around a little bit cperson has an excellent in depth guide on passing arrays to functions and back again. When in doubt, check cperson. He has a load of useful stuff regarding VBA






share|improve this answer























  • Hello Mr. Burns, thank you very much for your answer! Now I get error code 13 - type mismatch. AND I edited my post, maybe my mistake is somewhere else?

    – McMuellermilch
    Mar 6 at 15:47












  • @McMuellermilch You now have a new issue, I recommend a new question. SO is to help everyone, present or future. My answer is now invalid when looking at your question now. I recommend rolling back your question to what it was originally and if my answer resolved that issue, mark it as accepted and then ask a new question with your new issue

    – Mr.Burns
    Mar 6 at 16:10












  • Will do, thank you very much!

    – McMuellermilch
    Mar 6 at 16:12










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55026636%2fbyref-argumenttype-mismatch-when-passing-an-array-to-a-sub-or-function%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














You are missing () in the function, an array needs () after the variable when passing it somewhere else so VBA knows it as an array



Private Sub whatever()
Dim arr(10, 2) As String
workArray arr
End Sub

Sub workArray(ByRef arr() As String)
'- do stuff here
End Sub


Edit



I look around a little bit cperson has an excellent in depth guide on passing arrays to functions and back again. When in doubt, check cperson. He has a load of useful stuff regarding VBA






share|improve this answer























  • Hello Mr. Burns, thank you very much for your answer! Now I get error code 13 - type mismatch. AND I edited my post, maybe my mistake is somewhere else?

    – McMuellermilch
    Mar 6 at 15:47












  • @McMuellermilch You now have a new issue, I recommend a new question. SO is to help everyone, present or future. My answer is now invalid when looking at your question now. I recommend rolling back your question to what it was originally and if my answer resolved that issue, mark it as accepted and then ask a new question with your new issue

    – Mr.Burns
    Mar 6 at 16:10












  • Will do, thank you very much!

    – McMuellermilch
    Mar 6 at 16:12















0














You are missing () in the function, an array needs () after the variable when passing it somewhere else so VBA knows it as an array



Private Sub whatever()
Dim arr(10, 2) As String
workArray arr
End Sub

Sub workArray(ByRef arr() As String)
'- do stuff here
End Sub


Edit



I look around a little bit cperson has an excellent in depth guide on passing arrays to functions and back again. When in doubt, check cperson. He has a load of useful stuff regarding VBA






share|improve this answer























  • Hello Mr. Burns, thank you very much for your answer! Now I get error code 13 - type mismatch. AND I edited my post, maybe my mistake is somewhere else?

    – McMuellermilch
    Mar 6 at 15:47












  • @McMuellermilch You now have a new issue, I recommend a new question. SO is to help everyone, present or future. My answer is now invalid when looking at your question now. I recommend rolling back your question to what it was originally and if my answer resolved that issue, mark it as accepted and then ask a new question with your new issue

    – Mr.Burns
    Mar 6 at 16:10












  • Will do, thank you very much!

    – McMuellermilch
    Mar 6 at 16:12













0












0








0







You are missing () in the function, an array needs () after the variable when passing it somewhere else so VBA knows it as an array



Private Sub whatever()
Dim arr(10, 2) As String
workArray arr
End Sub

Sub workArray(ByRef arr() As String)
'- do stuff here
End Sub


Edit



I look around a little bit cperson has an excellent in depth guide on passing arrays to functions and back again. When in doubt, check cperson. He has a load of useful stuff regarding VBA






share|improve this answer













You are missing () in the function, an array needs () after the variable when passing it somewhere else so VBA knows it as an array



Private Sub whatever()
Dim arr(10, 2) As String
workArray arr
End Sub

Sub workArray(ByRef arr() As String)
'- do stuff here
End Sub


Edit



I look around a little bit cperson has an excellent in depth guide on passing arrays to functions and back again. When in doubt, check cperson. He has a load of useful stuff regarding VBA







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 6 at 15:32









Mr.BurnsMr.Burns

5261720




5261720












  • Hello Mr. Burns, thank you very much for your answer! Now I get error code 13 - type mismatch. AND I edited my post, maybe my mistake is somewhere else?

    – McMuellermilch
    Mar 6 at 15:47












  • @McMuellermilch You now have a new issue, I recommend a new question. SO is to help everyone, present or future. My answer is now invalid when looking at your question now. I recommend rolling back your question to what it was originally and if my answer resolved that issue, mark it as accepted and then ask a new question with your new issue

    – Mr.Burns
    Mar 6 at 16:10












  • Will do, thank you very much!

    – McMuellermilch
    Mar 6 at 16:12

















  • Hello Mr. Burns, thank you very much for your answer! Now I get error code 13 - type mismatch. AND I edited my post, maybe my mistake is somewhere else?

    – McMuellermilch
    Mar 6 at 15:47












  • @McMuellermilch You now have a new issue, I recommend a new question. SO is to help everyone, present or future. My answer is now invalid when looking at your question now. I recommend rolling back your question to what it was originally and if my answer resolved that issue, mark it as accepted and then ask a new question with your new issue

    – Mr.Burns
    Mar 6 at 16:10












  • Will do, thank you very much!

    – McMuellermilch
    Mar 6 at 16:12
















Hello Mr. Burns, thank you very much for your answer! Now I get error code 13 - type mismatch. AND I edited my post, maybe my mistake is somewhere else?

– McMuellermilch
Mar 6 at 15:47






Hello Mr. Burns, thank you very much for your answer! Now I get error code 13 - type mismatch. AND I edited my post, maybe my mistake is somewhere else?

– McMuellermilch
Mar 6 at 15:47














@McMuellermilch You now have a new issue, I recommend a new question. SO is to help everyone, present or future. My answer is now invalid when looking at your question now. I recommend rolling back your question to what it was originally and if my answer resolved that issue, mark it as accepted and then ask a new question with your new issue

– Mr.Burns
Mar 6 at 16:10






@McMuellermilch You now have a new issue, I recommend a new question. SO is to help everyone, present or future. My answer is now invalid when looking at your question now. I recommend rolling back your question to what it was originally and if my answer resolved that issue, mark it as accepted and then ask a new question with your new issue

– Mr.Burns
Mar 6 at 16:10














Will do, thank you very much!

– McMuellermilch
Mar 6 at 16:12





Will do, thank you very much!

– McMuellermilch
Mar 6 at 16:12



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55026636%2fbyref-argumenttype-mismatch-when-passing-an-array-to-a-sub-or-function%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved