macros_code
macros_code
' -------------------------
' Macro 2 – Check Positive, Negative, or Zero (A1)
' -------------------------
Sub CheckSign()
Dim num As Double
num = Range("A1").Value
With Range("A1").Interior
If num > 0 Then
.Color = vbGreen
ElseIf num < 0 Then
.Color = vbRed
Else
.Color = vbWhite
End If
End With
End Sub
' -------------------------
' Macro 3 – Check Signs in Column A (First 50 values)
' -------------------------
Sub CheckColumnSigns()
Dim i As Integer
For i = 1 To 50
If Cells(i, 1).Value > 0 Then
Cells(i, 2).Value = "Positive"
ElseIf Cells(i, 1).Value < 0 Then
Cells(i, 2).Value = "Negative"
Else
Cells(i, 2).Value = "Zero"
End If
Next i
End Sub
' -------------------------
' Macro 4 – Sum Numbers in Column A (First 50 rows)
' -------------------------
Sub SumColumnA()
Dim i As Integer, total As Double
total = 0
For i = 1 To 50
total = total + Cells(i, 1).Value
Next i
MsgBox "The sum of the numbers in column A is: " & total
End Sub
' -------------------------
' Macro 5 – 10x10 Multiplication Table
' -------------------------
Sub MultiplicationTable()
Dim i As Integer, j As Integer
For i = 1 To 10
For j = 1 To 10
Cells(i, j).Value = i * j
Next j
Next i
End Sub