KEMBAR78
Dividir Excel | PDF
0% found this document useful (0 votes)
11 views1 page

Dividir Excel

Uploaded by

209industries
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

Dividir Excel

Uploaded by

209industries
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Sub DividirCeldas()

Dim ws As Worksheet
Dim lastRow As Long
Dim i As Long, j As Long
Dim valoresA() As String, valoresF() As String
Dim nuevaFila As Long
Dim numFilas As Long

Set ws = ThisWorkbook.Sheets("Prepago")
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
nuevaFila = lastRow + 1

For i = 2 To lastRow
valoresA = Split(Replace(ws.Cells(i, 1).Value, ",", vbLf), vbLf)
valoresF = Split(Replace(ws.Cells(i, 6).Value, ",", vbLf), vbLf)

numFilas = Application.WorksheetFunction.Max(UBound(valoresA) + 1,
UBound(valoresF) + 1)

For j = 0 To numFilas - 1
ws.Cells(nuevaFila, 1).Value = IIf(j <= UBound(valoresA), valoresA(j),
"")
ws.Cells(nuevaFila, 6).Value = IIf(j <= UBound(valoresF), valoresF(j),
"")
ws.Cells(nuevaFila, 2).Resize(, 4).Value = ws.Cells(i, 2).Resize(,
4).Value
ws.Cells(nuevaFila, 7).Resize(, 3).Value = ws.Cells(i, 7).Resize(,
3).Value
ws.Cells(nuevaFila, 11).Value = ws.Cells(nuevaFila, 7).Value +
CalcularComision(ws.Cells(nuevaFila, 7).Value)
ws.Cells(nuevaFila, 12).Value = CalcularPrecio2(ws.Cells(nuevaFila,
7).Value)
nuevaFila = nuevaFila + 1
Next j
Next i
End Sub

You might also like