Gráficas

Buen día tengan todos ustedes, en esta ocasión programaremos en excel la representación de determinadas formulas como los son:  x², x³, raíz cuadrada, 1/x, sin(x), cos(x). 
Es importante que en excel activen la pestaña de desarrollador en la parte de configuración, ya teniendo este apartado tenemos en la parte de diseño varios elementos, ingresamos scroll bar y Boton para que este sea el que grafique y evalue
  
Set migrafica = ActiveWorkbook.Sheets("Hoja1").ChartObjects.Add(200, 45, 400, 400)
    migrafica.Chart.ChartType = xlXYScatterSmooth
    migrafica.Name = "f(x)"
    migrafica.Chart.SeriesCollection.NewSeries.Select
With Selection
    .XValues = Range(Cells(fini, x), Cells(ffinal, x))
    .Values = Range(Cells(fini, y), Cells(ffinal, y))


Private Sub CommandButton1_Click()
Dim a, b, c, li, ls, i As Integer
Dim res As Single
a = Range("b1").Value
b = Range("b2").Value
c = Range("b3").Value
li = Range("e1").Value
ls = Range("e2").Value
i = 6
While i <= (ls - li) + 6
Cells(i, 2).Value = li + (i - 6)
Cells(i, 3).Value = (a * (Cells(i, 2).Value * Cells(i, 2).Value)) + (b * Cells(i, 2).Value) + c
i = i + 1
Wend

crea_grafica (2), 3, 6, (ls - li) + 6





Private Sub CommandButton1_Click()
Dim li, ls, i As Double
Dim res As Single
li = Range("e1").Value
ls = Range("e2").Value
i = 6
While i <= (ls - li) + 6
Cells(i, 2).Value = li + (i - 6)
Cells(i, 3).Value = Sqr(Cells(i, 2).Value)
i = i + 1
Wend

crea_grafica (2), 3, 6, (ls - li) + 6



Private Sub CommandButton1_Click()
Dim li, ls, i As Integer
Dim res As Single
li = Range("e1").Value
ls = Range("e2").Value
i = 6
While i <= (ls - li) + 6
Cells(i, 2).Value = li + (i - 6)
Cells(i, 3).Value = Cos(Cells(i, 2).Value)
i = i + 1
Wend

crea_grafica (2), 3, 6, (ls - li) + 6

End Sub



Private Sub CommandButton1_Click()
Dim a, b, c, d, li, ls, i As Integer
Dim res As Single
a = Range("b1").Value
b = Range("b2").Value
c = Range("h1").Value
d = Range("h2").Value
li = Range("e1").Value
ls = Range("e2").Value
i = 6
While i <= (ls - li) + 6
Cells(i, 2).Value = li + (i - 6)
Cells(i, 3).Value = (a * (Cells(i, 2).Value * Cells(i, 2).Value * Cells(i, 2).Value)) + (b * (Cells(i, 2).Value * Cells(i, 2).Value)) + (c * Cells(i, 2).Value) + d
i = i + 1
Wend

crea_grafica (2), 3, 6, (ls - li) + 6

End Sub




Private Sub CommandButton1_Click()
Dim li, ls, i As Integer
Dim res As Single
li = Range("e1").Value
ls = Range("e2").Value
i = 6
While i <= (ls - li) + 6
Cells(i, 2).Value = li + (i - 6)
Cells(i, 3).Value = 1 / Cells(i, 2).Value
i = i + 1
Wend

crea_grafica (2), 3, 6, (ls - li) + 6

End Sub

A continuación les dejo los resultados de los códigos ya con gráfica.
Espero que sea util, muchas gracias 








Comentarios

Entradas populares de este blog

Suma en Espiral de una Matriz