Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Function Bar(r As Range) As Integer
- If r.Value = 2 Then
- Bar = 0
- Else
- Bar = 128
- End If
- End Function
- def safeDivide(numerator, cellRange):
- if not isinstance(cellRange, CellRange):
- raise ValueError('denominator must be a cell range')
- denominator = cellRange.Value
- if denominator == 0:
- cell = cellRange.TopLeft
- cell.BackColor = Color.Red
- cell.Offset(1, 0).Value = 'Tried to divide by zero'
- return 0
- return numerator / denominator
- Option Explicit
- Declare Function SetTimer Lib "user32" (ByVal HWnd As Long, _
- ByVal IDEvent As Long, ByVal mSec As Long, _
- ByVal CallFunc As Long) As Long
- Declare Function KillTimer Lib "user32" (ByVal HWnd As Long, _
- ByVal timerId As Long) As Long
- Private timerId As Long
- Private wb As Workbook
- Private rangeName As String
- Private blnFinished As Boolean
- Public Sub RunTimer()
- timerId = SetTimer(0, 0, 10, AddressOf Woohoo)
- End Sub
- Public Sub Woohoo()
- Dim i As Integer
- ' For i = 0 To ThisWorkbook.Names.Count - 1
- ' ThisWorkbook.Names(i).Delete
- ' Next
- ThisWorkbook.Worksheets("Sheet1").Range("D8").Value = "Woohoo"
- KillTimer 0, timerId
- End Sub
- Dim busy As Boolean
- Private Sub Worksheet_Change(ByVal Target As Range)
- If busy Then Exit Sub
- busy = True
- If Target.Row <= 10 And Target.Column <= 10 Then
- With Target.Offset(0, 1)
- If IsNumeric(Target) Then
- .Value = Target * 4
- .Interior.Color = RGB(212, 212, 255)
- Else
- .Value = Empty
- .Interior.ColorIndex = xlColorIndexNone
- End If
- End With
- End If
- busy = False
- End Sub
Add Comment
Please, Sign In to add comment