Question

Use VBA to create a table of FX FX in Excel for 0 <xs 10 incrementing x by 0.1. FX EX

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Sub CreateTable()

   

    Dim wsTest As Worksheet

   

    '''Sheet Name

    SheetName = "Table"

    Set wsTest = Nothing

   

    On Error Resume Next

    Set wsTest = ActiveWorkbook.Worksheets(SheetName)

    On Error GoTo 0

    

    If wsTest Is Nothing Then

        Worksheets.Add.Name = SheetName   '''If sheet is not exist

    End If

    Sheets(SheetName).Select

   

    '''Columns Names

    Range("A1").Value = "x"

    Range("B1").Value = "y=x^-2"

    Range("C1").Value = "y=x^-1"

    Range("D1").Value = "y=x^0"

    Range("E1").Value = "y=x^1"

    Range("F1").Value = "y=x^2"

    Range("G1").Value = "y=x^3"

   

    x = 0

    Row = 2

    Do While x <= 10

        If x = 0 Then

            x = x + 0.1

        End If

       

        '''Formulas

        Cells(Row, 1).Value = x

        Cells(Row, 2).Value = x ^ -2

        Cells(Row, 3).Value = x ^ -1

        Cells(Row, 4).Value = x ^ 0

        Cells(Row, 5).Value = x ^ 1

        Cells(Row, 6).Value = x ^ 2

        Cells(Row, 7).Value = x ^ 3

        Row = Row + 1

        x = x + 0.1

    Loop

   

    '''Draw Borders

    Range("A1").Select

    Range(Selection, Selection.End(xlDown)).Select

    Range(Selection, Selection.End(xlToRight)).Select

    Selection.Borders(xlDiagonalDown).LineStyle = xlNone

    Selection.Borders(xlDiagonalUp).LineStyle = xlNone

    With Selection.Borders(xlEdgeLeft)

        .LineStyle = xlContinuous

        .ColorIndex = 0

        .TintAndShade = 0

        .Weight = xlThin

    End With

    With Selection.Borders(xlEdgeTop)

        .LineStyle = xlContinuous

        .ColorIndex = 0

        .TintAndShade = 0

        .Weight = xlThin

    End With

    With Selection.Borders(xlEdgeBottom)

        .LineStyle = xlContinuous

        .ColorIndex = 0

        .TintAndShade = 0

        .Weight = xlThin

    End With

    With Selection.Borders(xlEdgeRight)

        .LineStyle = xlContinuous

        .ColorIndex = 0

        .TintAndShade = 0

        .Weight = xlThin

    End With

    With Selection.Borders(xlInsideVertical)

        .LineStyle = xlContinuous

        .ColorIndex = 0

        .TintAndShade = 0

        .Weight = xlThin

    End With

    With Selection.Borders(xlInsideHorizontal)

        .LineStyle = xlContinuous

        .ColorIndex = 0

        .TintAndShade = 0

        .Weight = xlThin

    End With

   

    '''Heading in Bold

    Range("A1:G1").Select

    Selection.Font.Bold = True

    ActiveWorkbook.Save

    MsgBox ("Done")

   

End Sub 100 10 0.1 0.2 0.1 0.2 0.3 11.11111 3.333333 0.4 0.5 0.4 0.5 0.6 0.7 0.8 0.9 0.01 0.04 0.09 0.16 0.25 0.36 0.49 0.64 0.81 0.001 0.008 0.027 0.064 0.125 0.216 0.343 0.512 0.729 6.25 2.5 4 0.7 2.0408161.428571 0.8 1.5625 1.25 10 12 13 14 15 16 17 1.1 0.8264460.909091 1.2 0.6944440.833333 1.3 0.5917160.769231 1.40.5102040.714286 1.5 0.4444440.666667 0.625 1.71 0.3460211 0.588235 1.8 0.308642 0.555556 1.9 0.2770080.526316 0.5 2.1 0.226757 0.47619 2.2 0.2066120.454545 2.3 0.1890360.434783 2.4 0.173611 0.416667 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 1.21 1.44 1.69 1.96 2.25 2.56 2.89 3.24 3.61 1.331 1.728 2.197 2.744 3.375 4.096 4.913 5.832 6.859 1.6 0.390625 19 0.25 4 4.41 4.8410.648 5.29 12.167 5.76 13.824 2.1 2.2 9.261 24 25 H 2.4 TableSheet1 Sheet2Sheet3

Add a comment
Know the answer?
Add Answer to:
Use VBA to create a table of in Excel for 0 < x lessthanorequalto 10 incrementing...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT