T
Tommy Flynn
What's wrong with this code? I'm getting a ByRef type mismatch error.
Sub SetRange()
Dim topCel As Range, bottomCel As Range
Set topCel = ActiveCell
If IsEmpty(topCel) Then Set topCel = topCel.End(xlDown)
Set bottomCel = Cells(65536, topCel.Column).End(xlUp)
If bottomCel.Row < topCel.Row Then Set topCel = bottomCel
Set myRng = Range(topCel, bottomCel)
myRng.NumberFormat = "@"
Call FormatCells(myRng)
End Sub
Sub FormatCells(ByRef myRng As Range)
For Each cel In myRng
If cel.Value < 1000 Then
cel.Value = "0" & Left(cel, 1) & ":00"
Else
cel.Value = Left(cel, 2) & ":00"
End If
Next
End Sub
Sub SetRange()
Dim topCel As Range, bottomCel As Range
Set topCel = ActiveCell
If IsEmpty(topCel) Then Set topCel = topCel.End(xlDown)
Set bottomCel = Cells(65536, topCel.Column).End(xlUp)
If bottomCel.Row < topCel.Row Then Set topCel = bottomCel
Set myRng = Range(topCel, bottomCel)
myRng.NumberFormat = "@"
Call FormatCells(myRng)
End Sub
Sub FormatCells(ByRef myRng As Range)
For Each cel In myRng
If cel.Value < 1000 Then
cel.Value = "0" & Left(cel, 1) & ":00"
Else
cel.Value = Left(cel, 2) & ":00"
End If
Next
End Sub