• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VB array variable type for ascii string

Status
Not open for further replies.

P0lar

Member
Hi,

I have a formula which creates a string including a superscript 0,1,2 or 3 - represented by chr(185), 186, 179 and 178:

¹0800-1500¹

I would like to pass this into an array in VB but can only fill the array with the #N/A "error 2042" for some reason, I suspect this may be due to the data type which is set as variant (I tried string data type as well)

Code:
 Dim OP(21) As Variant
j = 9 to 27
OP(j - 9) = Sheets("Filter").Range("O20") 'the cell with the above string in it
next j
 
is this all your code..
No FOR, No SUB..
Only put the same data in all fields of array!!!
 
Hi, P0lar!

Give a look at the uploaded file.

Formula for A column:
A1: =CARACTER(ELEGIR(ALEATORIO.ENTRE(1;3);185;186;179))&"0800-1500"&CARACTER(ELEGIR(ALEATORIO.ENTRE(1;3);185;186;179)) -----> in english: =CHAR(CHOOSE(RANDBETWEEN(1,3),185,186,179))&"0800-1500"&CHAR(CHOOSE(RANDBETWEEN(1,3),185,186,179))

This is the code:
Code:
Option Explicit

Sub ItWorksDoesntIt()
    Dim OP(21) As Variant
    Dim J As Integer
    With Worksheets("Hoja1")
        For J = 0 To 20
            OP(J) = Worksheets("Hoja1").Cells(J + 1, 1).Value
            Debug.Print J, OP(J)
        Next J
        .Columns(2).ClearContents
        For J = 0 To 20
            Worksheets("Hoja1").Cells(J + 1, 2).Value = OP(J)
        Next J
    End With
End Sub
Check column B properly filled from array.

Regards!
 

Attachments

  • VB array variable type for ascii string (for P0lar at chandoo.xlsm
    15.9 KB · Views: 1
Status
Not open for further replies.
Back
Top