Macro parra pasar a la siguiente fila
Publicado por Jorge Luis (43 intervenciones) el 22/03/2013 15:53:32
estoy haciendo un ejercicio en el cual me piden el ingreso de datos, he escrito el código para que me llene los datos que me piden pero no se como una vez termine de llenar la primera fila como paso a la segunda y tercera fila y como hallo el promedio del Costo Promedio
Su ayuda por favor
Sub almacen()
Dim code As String
Dim descri As String
Dim precio As String
Dim pausa As String
Dim prom As String
Dim i As Integer
'Call Titulo_Cervantes ( Este código abajo señalado lo he hecho con una macro grabada , pero se puede hacer con un código mas corto pero me lo pidieron así )
Range("B4").Select
ActiveCell.FormulaR1C1 = "Código Producto"
Range("C4").Select
ActiveCell.FormulaR1C1 = "Descripción"
Range("D4").Select
ActiveCell.FormulaR1C1 = "Precio Costo"
Range("B4:D4").Select
Selection.Font.Bold = True
Selection.Font.Italic = True
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 5296274
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("B5").Select
pausa = InputBox("¿Desea ingresar información? si/no:")
Do While pausa = "si"
code = InputBox("Ingrese el código del Producto: ")
Range("A5").Value = code
descri = InputBox("Ingrese la Descripción del Producto: ")
Range("B5").Value = descri
precio = InputBox("Ingrese el Precio Costo del : ")
Range("C5").Value = precio
pausa = InputBox("¿Desea continuar? si/no:", "Control")
Loop
'Como hallo el promedio de la columna precio si son tres o mas filas
End Sub
Su ayuda por favor
Sub almacen()
Dim code As String
Dim descri As String
Dim precio As String
Dim pausa As String
Dim prom As String
Dim i As Integer
'Call Titulo_Cervantes ( Este código abajo señalado lo he hecho con una macro grabada , pero se puede hacer con un código mas corto pero me lo pidieron así )
Range("B4").Select
ActiveCell.FormulaR1C1 = "Código Producto"
Range("C4").Select
ActiveCell.FormulaR1C1 = "Descripción"
Range("D4").Select
ActiveCell.FormulaR1C1 = "Precio Costo"
Range("B4:D4").Select
Selection.Font.Bold = True
Selection.Font.Italic = True
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 5296274
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("B5").Select
pausa = InputBox("¿Desea ingresar información? si/no:")
Do While pausa = "si"
code = InputBox("Ingrese el código del Producto: ")
Range("A5").Value = code
descri = InputBox("Ingrese la Descripción del Producto: ")
Range("B5").Value = descri
precio = InputBox("Ingrese el Precio Costo del : ")
Range("C5").Value = precio
pausa = InputBox("¿Desea continuar? si/no:", "Control")
Loop
'Como hallo el promedio de la columna precio si son tres o mas filas
End Sub
Valora esta pregunta
0