Why doen't this assignment work

Mackeral

Board Regular
Joined
Mar 7, 2015
Messages
232
Office Version
  1. 365
Platform
  1. Windows
Definition Line
VBA Code:
Public Test_Stings(20) as String

When I execute
VBA Code:
Test_Strings(1) = "ABC"
I get this message
VBA Code:
Run time Error
Type 13
I want "Test_Strings" to hold "Strings", not "Integers".

What have I not understood?
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
I would suggest that you use Option Explicit. That would show that you have a typo.
 
Upvote 0
The problem turned out to be that I was trying to also pass"Test_Strings" as an subroutine argument.
 
Upvote 0
For what you posted, and what Fluff was trying to lead you to, is that the spelling of your variable name in the Dim statement was different from that in your assignment statement. Using Option Explicit will protect you against that, and a whole host of other, errors.
 
Upvote 0
I went back and fixed the calls, but I'm still getting a the same "Type Mismatch" error.

The argument definition is in the same module as the code.
 
Upvote 0
I found another local definitions for "Test_Strings" defined as Interger. Took that out, and it works fine.
 
Upvote 0
Solution
I am glad you found the problem because I was about to write back that I saw nothing wrong with the code you showed us (once the variable names were taken care of).
 
Upvote 0

Forum statistics

Threads
1,214,872
Messages
6,122,025
Members
449,060
Latest member
LinusJE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top