 |
VBA Prime Number Highlighter by: dogstar |
Composed on: Aug., 01 2007 (2:06 pm) |
Hello,
Below is my code to highlight a prime number.
Dogstar
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 1/3/2007 by Dogstar
'
' Keyboard Shortcut: Ctrl+p
Dim numSqr As Integer
Dim numRem
numSqr = (ActiveCell.Value) ^ 0.5
For i = 2 To numSqr
If ActiveCell.Value Mod i = 0 Then GoTo 3836 'not prime
Next i
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
3836
Down
End Sub
Sub Down()
ActiveCell.Offset(1, 0).Select
End Sub
No Comments for this page.
|