PARTIR ARRAY

galileogali

Well-known Member
Joined
Oct 14, 2005
Messages
748
Tengo un ARRAY por ejemplo Bidimensional:
Mimatriz ( 1 to 70536) .
Quiero dividirlo en dos; MiMatrizSh1(1 to 65536, 1 to 1) y MiMatrizSh2(65537 to 70536, 1 to 1)

¿¿Existe alguna Forma de hacer esta division sin necesidad de Loopear en un FOR NEXT, SIN PERDER LOS DATOS, desde ya???

(Tambien seria válida una división como esta:MiMatrizSh1(1 to 65536, 1 to 1) y MiMatrizSh2(1 to 5536, 1 to 1)

He probado con REDIM PRESERVE, pero no lo logro.
 
Hola Gali,

Por fin tuve tiempo para ver eso. ¡Muey bien! Una cosa, uno no puede pasar una matriz asi ByVal solamente ByRef. Entonces realmente los cambios a x() van a impactar Arrx entonces cambié eso a una rutina en vez de una función y puse "ByRef" asi uno no piensa que Arrx queda sin estar tocado.
Code:
Sub EliminaItem(ByRef x() As String, n As Long)

    '// not putting in a blank because it is conceivable that the 
    '// inbound array contains empty elements. We are trying to delete
    '// a specific element, not a specific element + all empty elements.    
    Const c_strUnlikelyString = "~!@#$%^%$#@!~"
    
    Dim strR As String, strToReplace As String, strNew As String

    If UBound(x) = 0 Then Exit Sub
    If n < LBound(x) Or n > UBound(x) Then Exit Sub
    
    Select Case n
        Case LBound(x)      ' first element, so no leading pipe
            strToReplace = c_strUnlikelyString & "|"
            strNew = vbNullString
        Case UBound(x)      ' last element, so no trailing pipe
            strToReplace = "|" & c_strUnlikelyString
            strNew = vbNullString
        Case Else           ' leading & trailing pipes
            strToReplace = "|" & c_strUnlikelyString & "|"
            strNew = "|"
    End Select
    
    x(n) = c_strUnlikelyString
    strR = Join(x, "|") 'rearmo la cadena
    strR = Replace(strR, strToReplace, strNew) 'elimino el espacio vacío
    x = Split(strR, "|") 'rearmo el ARRAY con la cadena disminuida

End Sub
 
Upvote 0

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
¡Uy! Se me olvidó decir que dado la forma nueva, cambié la llamada a tal:
Code:
    'Arrx = EliminaItem(Arrx, n)
    EliminaItem Arrx, n - 1
 
Upvote 0
Greg:
Gracias por haber puesto tu atencion en esto.
Yo recien arribo de mis vacaciones. En cuanto pueda revisare tu aporte
y generare mis comentarios.

Thanks
 
Upvote 0

Forum statistics

Threads
1,223,958
Messages
6,175,637
Members
452,663
Latest member
MEMEH

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