Excel - sumar columna y llenar en un vsFlexArray1(Msflexg)

 
Vista:

sumar columna y llenar en un vsFlexArray1(Msflexg)

Publicado por Catita (2 intervenciones) el 06/11/2009 13:48:39
Hola tengo un gran problema que no puedo resolverlo
tengo una hoja con registros, lo que quiero es; si el articulo y el corte de la fila es igual al de la siguiente fila que se sumen las cantidades de las columnas 4 y 5. y los envie a un msflexgrid, de lo contrario que copie los datos en la siguiente fila del msflexgrid (msflexgrid o vsFlexArray tiene las mismas caracteristicas y se puede decir que trabajan de la misma manera)

me copia casitodos los datos, excepto no me copia la suma real de las columnas 4 y 5 .algunos productos se suman correctamente y otros no.

Aqui les envio el codigo en prueba y la descripcion de los datos

Almc--> sucursal de la empresa
Articulo-->codigo del producto
Corte-->tiempo de duracion del producto
Ord-->cantidad ordenado por el cliente
Asig-->cantidad asgnada por el sistema
Stock-->inventario de la bodega
TotAsig-->total de producto asignado por el sistema
TotOrden-->total ordenado por los clientes

Almc- Articulo- Corte- Ord- Asig- Stock- totAsig- totOrden
400- 100103- 90- 5- 0- 0- 0- 83
200- 100103- 95- 150- 0- 155- 1637- 4872
500- 100103- 95- 100- 0- 7- 2- 225
500- 100103- 95- 50- 0- 7- 2- 225
200- 120121- 0- 34- 34- 412- 60- 64
200- 120121- 0- 5- 5- 412- 60- 64
400- 120121- 0- 2- 2- 412- 60- 64
200- 120121- 0- 5- 0- 412- 60- 64
200- 120121- 90- 2- 2- 412- 60- 64
200- 120121- 90- 3- 3- 412- 60- 64
200vr- 120121- 120- 1- 1- 412- 60- 64
200- 120121- 125- 1- 1- 412- 60- 64
200- 120121- 140- 2- 2- 412- 60- 64
200- 120130- 120- 1- 0- 0- 0- 1
200- 120261- 0- 8- 8- 1442- 183- 185
200VR- 120261- 0- 5- 5- 1442- 183- 185
200- 120261- 0- 3- 0- 1442- 183- 185
200- 120624- 135- 2- 0- 5486- 907- 1019
200- 120624- 135- 5- 0- 5486- 907- 1019
200- 120624- 135- 1- 0- 5486- 907- 1019
500- 120624- 135- 3- 0- 479- 10- 14
200- 120624- 140- 5- 0- 5486- 907- 1019
300- 410010- 0- 2- 0- 0- 0- 37
200- 410010- 0- 2- 0- 0- 0- 37
200- 410010- 0- 1- 0- 0- 0- 37
200VR- 410010- 0- 1- 0- 0- 0- 37
200- 410010- 0- 1- 0- 0- 0- 37
500- 410010- 0- 1- 0- 1- 1- 5
500- 410010- 0- 1- 0- 1- 1- 5
200- 410010- 30- 2- 0- 0- 0- 37
200- 410010- 30- 1- 0- 0- 0- 37
200- 410010- 30- 2- 0- 0- 0- 37
200- 410010- 30- 1- 0- 0- 0- 37
200VR- 410010- 30- 1- 0- 0- 0- 37
500- 410010- 30- 1- 0- 1- 1- 5
200- 410010- 41- 1- 0- 0- 0- 37
200vr- 410010- 41- 1- 0- 0- 0- 37
200- 410010- 41- 1- 0- 0- 0- 37
200- 410010- 41- 1- 0- 0- 0- 37
200- 490005- 30- 1- 1- 274- 24- 24
200- 490005- 30- 1- 1- 274- 24- 24

Private Sub OptionButton1_Click()
Dim filaB As Integer, fila1 As Integer, filaA As Integer, ORD As Long, ASIG As Long, PICK As Long
If UserForm1.Caption = " STOCK DISPONIBLE PARA DEMANDA: ASIGNACION" Then
If OptionButton1.Value = True Then
vsFlexArray1.Rows = 2
For Z = 1 To vsFlexArray1.Cols - 1
vsFlexArray1.TextMatrix(1, Z) = ""
Next Z
'Call limpiar
filaB = 2
While Worksheets("ASG 61,10,2").Cells(filaB, 17).Value <> ""
filaB = filaB + 1
Wend
filaA = 1

For fila1 = 2 To filaB
If Worksheets("ASG 61,10,2").Cells(fila1, 1).Value = 200 Or Worksheets("ASG 61,10,2").Cells(fila1, 1).Value = "200VR" Or _
Worksheets("ASG 61,10,2").Cells(fila1, 1).Value = "200vr" Then
If (Worksheets("ASG 61,10,2").Cells(fila1, 6).Value >= Worksheets("ASG 61,10,2").Cells(fila1, 8).Value) And _
(Worksheets("ASG 61,10,2").Cells(fila1, 5).Value < Worksheets("ASG 61,10,2").Cells(fila1, 4).Value) Then

If (Worksheets("ASG 61,10,2").Cells(fila1, 2).Value = Worksheets("ASG 61,10,2").Cells(fila1 + 1, 2).Value) And _
(Worksheets("ASG 61,10,2").Cells(fila1, 3).Value = Worksheets("ASG 61,10,2").Cells(fila1 + 1, 3).Value) Then

vsFlexArray1.RowHeight(filaA) = 270
vsFlexArray1.TextMatrix(filaA, 1) = Worksheets("ASG 61,10,2").Cells(fila1, 9).Value
vsFlexArray1.TextMatrix(filaA, 2) = Worksheets("ASG 61,10,2").Cells(fila1, 1).Value
vsFlexArray1.TextMatrix(filaA, 3) = Worksheets("ASG 61,10,2").Cells(fila1, 2).Value
vsFlexArray1.TextMatrix(filaA, 6) = Worksheets("ASG 61,10,2").Cells(fila1, 3).Value vsFlexArray1.TextMatrix(filaA, 8) = Worksheets("ASG 61,10,2").Cells(fila1, 6).Value
vsFlexArray1.TextMatrix(filaA, 9) = Worksheets("ASG 61,10,2").Cells(fila1, 8).Value
vsFlexArray1.TextMatrix(filaA, 4) = Val(vsFlexArray1.TextMatrix(filaA, 4)) + Worksheets("ASG 61,10,2").Cells(fila1, 4).Value
vsFlexArray1.TextMatrix(filaA, 5) = Val(vsFlexArray1.TextMatrix(filaA, 5)) + Worksheets("ASG 61,10,2").Cells(fila1, 5).Value
vsFlexArray1.TextMatrix(filaA, 7) = Val(vsFlexArray1.TextMatrix(filaA, 11)) + Worksheets("ASG 61,10,2").Cells(fila1, 7).Value


ElseIf (Worksheets("ASG 61,10,2").Cells(fila1, 2).Value <> Worksheets("ASG 61,10,2").Cells(fila1 + 1, 2).Value Or _
Worksheets("ASG 61,10,2").Cells(fila1, 3).Value <> Worksheets("ASG 61,10,2").Cells(fila1 + 1, 3).Value) Then
vsFlexArray1.RowHeight(filaA) = 270
vsFlexArray1.TextMatrix(filaA, 4) = Val(vsFlexArray1.TextMatrix(filaA,4)) + Worksheets("ASG 61,10,2").Cells(fila1, 4).Value
vsFlexArray1.TextMatrix(filaA, 5) = Val(vsFlexArray1.TextMatrix(filaA, 5)) + Worksheets("ASG 61,10,2").Cells(fila1, 5).Value
vsFlexArray1.TextMatrix(filaA, 7) = Val(vsFlexArray1.TextMatrix(filaA, 7)) + Worksheets("ASG 61,10,2").Cells(fila1, 7).Value
vsFlexArray1.TextMatrix(filaA, 2) = Worksheets("ASG 61,10,2").Cells(fila1, 1).Value
vsFlexArray1.TextMatrix(filaA, 3) = Worksheets("ASG 61,10,2").Cells(fila1, 2).Value vsFlexArray1.TextMatrix(filaA, 6) = Worksheets("ASG 61,10,2").Cells(fila1, 3).Value vsFlexArray1.TextMatrix(filaA, 8) = Worksheets("ASG 61,10,2").Cells(fila1, 6).Value vsFlexArray1.TextMatrix(filaA, 9) = Worksheets("ASG 61,10,2").Cells(fila1, 8).Value filaA = filaA + 1
vsFlexArray1.Rows = vsFlexArray1.Rows + 1

End If
End If
End If
Next fila1
End If
End if

Espero su ayuda, Gracias

Atte.

Catita
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:sumar columna y llenar en un vsFlexArray1(Msfle

Publicado por Catita (5 intervenciones) el 11/11/2009 00:09:57
Muchachos ya encontre la solucion, les mando el codigo por si alguien llegara a tener el mismo problema.

Almc--> sucursal de la empresa
Articulo-->codigo del producto
Corte-->tiempo de duracion del producto
Ord-->cantidad ordenado por el cliente
Asig-->cantidad asgnada por el sistema
Stock-->inventario de la bodega
TotAsig-->total de producto asignado por el sistema
TotOrden-->total ordenado por los clientes
"con este codigo cargo y sumo los datos en la columna 56-57-58"

Private Sub Worksheet_Activate()
Dim ORD As Long, ASIG As Long, PICK As Long, FILAA As Integer, FILA1 As Integer
Dim ws1 As Worksheet
Worksheets("ASG 61,10,2").Range("BD2:BF9000").Value = Empty
With Application
.ScreenUpdating = False
old = .Calculation
.Calculation = xlCalculationManual
.EnableEvents = False
End With
Set ws1 = Worksheets("ASG 61,10,2")

filaB = 2
While ws1.Cells(filaB, 17).Value <> ""
filaB = filaB + 1
Wend
FILAA = 1
ORD = 0
ASIG = 0
PICK = 0
For FILA1 = 2 To filaB

If (ws1.Cells(FILA1, 24).Value >= ws1.Cells(FILA1, 38).Value And _
ws1.Cells(FILA1, 21).Value < ws1.Cells(FILA1, 20).Value) And _
(ws1.Cells(FILA1, 17).Value = ws1.Cells(FILA1 + 1, 17).Value And _
ws1.Cells(FILA1, 19).Value = ws1.Cells(FILA1 + 1, 19).Value And _
ws1.Cells(FILA1, 9).Value = ws1.Cells(FILA1 + 1, 9).Value) Then

ORD = ORD + ws1.Cells(FILA1, 20).Value
ASIG = ASIG + ws1.Cells(FILA1, 21).Value
PICK = PICK + ws1.Cells(FILA1, 22).Value
ElseIf (ws1.Cells(FILA1, 17).Value = ws1.Cells(FILA1 + 1, 17).Value And _
ws1.Cells(FILA1, 19).Value = ws1.Cells(FILA1 + 1, 19).Value And _
ws1.Cells(FILA1, 9).Value = ws1.Cells(FILA1 + 1, 9).Value) And _
(ws1.Cells(FILA1, 21).Value = ws1.Cells(FILA1, 20).Value) Then

ws1.Cells(FILA1, 56).Value = ORD
ws1.Cells(FILA1, 57).Value = ASIG
ws1.Cells(FILA1, 58).Value = PICK
ORD = 0
ASIG = 0
PICK = 0
ElseIf (ws1.Cells(FILA1, 17).Value <> ws1.Cells(FILA1 + 1, 17).Value Or _
ws1.Cells(FILA1, 19).Value <> ws1.Cells(FILA1 + 1, 19).Value Or _
ws1.Cells(FILA1, 9).Value <> ws1.Cells(FILA1 + 1, 9).Value) And _
(ws1.Cells(FILA1, 21).Value = ws1.Cells(FILA1, 20).Value) Then

ws1.Cells(FILA1, 56).Value = ORD
ws1.Cells(FILA1, 57).Value = ASIG
ws1.Cells(FILA1, 58).Value = PICK
ORD = 0
ASIG = 0
PICK = 0
ElseIf (ws1.Cells(FILA1, 24).Value < ws1.Cells(FILA1, 38).Value And _
ws1.Cells(FILA1, 21).Value < ws1.Cells(FILA1, 20).Value) And _
(ws1.Cells(FILA1, 17).Value = ws1.Cells(FILA1 + 1, 17).Value And _
ws1.Cells(FILA1, 19).Value = ws1.Cells(FILA1 + 1, 19).Value And _
ws1.Cells(FILA1, 9).Value = ws1.Cells(FILA1 + 1, 9).Value) Then

ws1.Cells(FILA1, 56).Value = ORD
ws1.Cells(FILA1, 57).Value = ASIG
ws1.Cells(FILA1, 58).Value = PICK
ORD = 0
ASIG = 0
PICK = 0
ElseIf (ws1.Cells(FILA1, 17).Value <> ws1.Cells(FILA1 + 1, 17).Value Or _
ws1.Cells(FILA1, 19).Value <> ws1.Cells(FILA1 + 1, 19).Value Or _
ws1.Cells(FILA1, 9).Value <> ws1.Cells(FILA1 + 1, 9).Value) And _
(ws1.Cells(FILA1, 21).Value < ws1.Cells(FILA1, 20).Value And _
ws1.Cells(FILA1, 24).Value < ws1.Cells(FILA1, 38).Value) Then

ws1.Cells(FILA1, 56).Value = ORD
ws1.Cells(FILA1, 57).Value = ASIG
ws1.Cells(FILA1, 58).Value = PICK
ORD = 0
ASIG = 0
PICK = 0
ElseIf (ws1.Cells(FILA1, 17).Value <> ws1.Cells(FILA1 + 1, 17).Value Or _
ws1.Cells(FILA1, 19).Value <> ws1.Cells(FILA1 + 1, 19).Value Or _
ws1.Cells(FILA1, 9).Value <> ws1.Cells(FILA1 + 1, 9).Value) And _
(ws1.Cells(FILA1, 21).Value < ws1.Cells(FILA1, 20).Value And _
ws1.Cells(FILA1, 24).Value >= ws1.Cells(FILA1, 38).Value) Then
ORD = ORD + ws1.Cells(FILA1, 20).Value
ASIG = ASIG + ws1.Cells(FILA1, 21).Value
PICK = PICK + ws1.Cells(FILA1, 22).Value

ws1.Cells(FILA1, 56).Value = ORD
ws1.Cells(FILA1, 57).Value = ASIG
ws1.Cells(FILA1, 58).Value = PICK
ORD = 0
ASIG = 0
PICK = 0
End If
Next FILA1
With Application
.ScreenUpdating = True
.Calculation = old
.EnableEvents = True
End With
Set ws1 = Nothing
End Sub

"aqui cargo los datos en el VSFLEXGRID"

Private Sub OptionButton1_Click()
Dim filaB As Integer, FILA1 As Integer, FILAA As Integer, ORD As Long, ASIG As Long, PICK As Long
Dim ws1 As Worksheet
With Application
.ScreenUpdating = False
old = .Calculation
.Calculation = xlCalculationManual
.EnableEvents = False
End With
Set ws1 = Worksheets("ASG 61,10,2")
If UserForm1.Caption = " STOCK DISPONIBLE PARA DEMANDA: ASIGNACION" Then
If OptionButton1.Value = True Then
vsFlexArray1.Rows = 2
For Z = 1 To vsFlexArray1.Cols - 1
vsFlexArray1.TextMatrix(1, Z) = ""
Next Z
filaB = 2
While ws1.Cells(filaB, 17).Value <> ""
filaB = filaB + 1
Wend
FILAA = 1

For FILA1 = 2 To filaB
If ws1.Cells(FILA1, 9).Value = 200 Or ws1.Cells(FILA1, 9).Value = "200VR" Or _
ws1.Cells(FILA1, 9).Value = "200vr" Then
If (ws1.Cells(FILA1, 24).Value >= ws1.Cells(FILA1, 38).Value) And _
(ws1.Cells(FILA1, 21).Value < ws1.Cells(FILA1, 20).Value) Then
If ws1.Cells(FILA1, 56).Value <> "" Or ws1.Cells(FILA1, 57).Value <> "" Or _
ws1.Cells(FILA1, 58).Value <> "" Then
vsFlexArray1.RowHeight(FILAA) = 270
vsFlexArray1.TextMatrix(FILAA, 1) = ws1.Cells(FILA1, 9).Value
vsFlexArray1.TextMatrix(FILAA, 2) = ws1.Cells(FILA1, 17).Value
vsFlexArray1.TextMatrix(FILAA, 3) = ws1.Cells(FILA1, 18).Value
vsFlexArray1.TextMatrix(FILAA, 8) = ws1.Cells(FILA1, 19).Value
vsFlexArray1.TextMatrix(FILAA, 4) = ws1.Cells(FILA1, 37).Value
vsFlexArray1.TextMatrix(FILAA, 5) = ws1.Cells(FILA1, 39).Value
vsFlexArray1.TextMatrix(FILAA, 6) = ws1.Cells(FILA1, 38).Value
vsFlexArray1.TextMatrix(FILAA, 7) = ws1.Cells(FILA1, 40).Value
vsFlexArray1.TextMatrix(FILAA, 9) = ws1.Cells(FILA1, 56).Value
vsFlexArray1.TextMatrix(FILAA, 10) = ws1.Cells(FILA1, 57).Value
vsFlexArray1.TextMatrix(FILAA, 11) = ws1.Cells(FILA1, 58).Value
vsFlexArray1.Rows = vsFlexArray1.Rows + 1
FILAA = FILAA + 1
End If
vsFlexArray1.CellForeColor = vbBlack
With vsFlexArray1
For X = 1 To .Rows - 1
.Col = 0
.Row = X
.Text = X
Next X

End With
End If
End If
Next FILA1
End If

ElseIf UserForm1.Caption = " STOCK DISPONIBLE PARA DEMANDA: PICKING" Then
If OptionButton1.Value = True Then
vsFlexArray1.Rows = 2
For Z = 1 To vsFlexArray1.Cols - 1
vsFlexArray1.TextMatrix(1, Z) = ""
Next Z

filaB = 2
While ws1.Cells(filaB, 9).Value <> ""
filaB = filaB + 1
Wend

FILAA = 1
For FILA1 = 2 To filaB
If ws1.Cells(FILA1, 9).Value = 200 Or ws1.Cells(FILA1, 9).Value = "200VR" Or _
ws1.Cells(FILA1, 9).Value = "200vr" Then
If (ws1.Cells(FILA1, 24).Value >= ws1.Cells(FILA1, 38).Value) And _
(ws1.Cells(FILA1, 21).Value < ws1.Cells(FILA1, 20).Value) Then
If ws1.Cells(FILA1, 56).Value <> "" Or ws1.Cells(FILA1, 57).Value <> "" Or _
ws1.Cells(FILA1, 58).Value <> "" Then
vsFlexArray1.RowHeight(FILAA) = 270
vsFlexArray1.TextMatrix(FILAA, 1) = ws1.Cells(FILA1, 9).Value
vsFlexArray1.TextMatrix(FILAA, 2) = ws1.Cells(FILA1, 17).Value
vsFlexArray1.TextMatrix(FILAA, 3) = ws1.Cells(FILA1, 18).Value
vsFlexArray1.TextMatrix(FILAA, 8) = ws1.Cells(FILA1, 19).Value
vsFlexArray1.TextMatrix(FILAA, 4) = ws1.Cells(FILA1, 37).Value
vsFlexArray1.TextMatrix(FILAA, 5) = ws1.Cells(FILA1, 39).Value
vsFlexArray1.TextMatrix(FILAA, 6) = ws1.Cells(FILA1, 38).Value
vsFlexArray1.TextMatrix(FILAA, 7) = ws1.Cells(FILA1, 40).Value
vsFlexArray1.TextMatrix(FILAA, 9) = ws1.Cells(FILA1, 56).Value
vsFlexArray1.TextMatrix(FILAA, 10) = ws1.Cells(FILA1, 57).Value
vsFlexArray1.TextMatrix(FILAA, 11) = ws1.Cells(FILA1, 58).Value
vsFlexArray1.Rows = vsFlexArray1.Rows + 1
FILAA = FILAA + 1
End If

vsFlexArray1.CellForeColor = vbBlack
With vsFlexArray1
For X = 1 To .Rows - 1
.Col = 0
.Row = X
.Text = X
Next X
End With
End If
End If
Next FILA1
End If
End If
With Application
.ScreenUpdating = True
.Calculation = old
.EnableEvents = True
End With
Set ws1 = Nothing
End Sub

Atte.

Catita Z.O.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar