View Single Post
  #2  
Old 06-30-2009, 05:13 PM
mehdoush mehdoush is offline
Registered User
 
Join Date: 20 Feb 2009
Location: La, CA
MS Office Version:Excel 2003
Posts: 70
mehdoush is becoming part of the community
Re: Runtime error 9 opening and editing macro

here's the decompose code

Code:
Sub decompose()
'decompose
Dim Rnng As Range, Dn As Range, oVal, oSp As Long
Dim Ray, cc As Long
Set Rnng = Range(Range("B3"), Range("B" & Rows.Count).End(xlUp))
ReDim Ray(1 To Rnng.Count * 4, 1 To 4)
For Each Dn In Rnng
    oVal = Split(Dn.Offset(, 3), "/")
     If UBound(oVal) > 0 Then
        For oSp = 0 To UBound(oVal)
            cc = cc + 1
            Ray(cc, 1) = Dn
            Ray(cc, 2) = Dn.Offset(, 1)
            Ray(cc, 3) = Dn.Offset(, 2)
            Ray(cc, 4) = oVal(oSp)
        Next oSp
    Else
        cc = cc + 1
        Ray(cc, 1) = Dn
        Ray(cc, 2) = Dn.Offset(, 1)
        Ray(cc, 3) = Dn.Offset(, 2)
        Ray(cc, 4) = Dn.Offset(, 3)
    End If
Next Dn

Range("B3").Resize(cc, 4).Value = Ray

'supprimer les lignes blank
'For i = Cells(Rows.Count, "D").End(xlUp).Row To 1 Step -1
'If IsEmpty(Cells(i, "D")) Then Rows(i).EntireRow.Delete
'Next i

End Sub
help plz
Reply With Quote