Question : VBA Looping through cells

I have a set of data that is automaticly updated, and it returns times in the C2:D100 cells. Except the values of this data are like: 11:11AM with no space. I have come up with a function that I thought would change the data to a value of: 11:11 AM (with a space between time and AM) this way the time format would apply to the time.

Sub SplitTime()
Dim LResult As Long
For Each cell In Range("C2:D200")
    If IsEmpty(cell) = False Then
    LResult = Len(cell) - 2
    ActiveSheet.cell.Value = Left(cell, LResult) & " " & Right(cell, 2)
    End If
Next cell
End Sub

I always get an error on the line:
    ActiveSheet.cell.Value = Left(cell, LResult) & " " & Right(cell, 2)
Error: Object doesn't support this property or method

I think is has something to do with the way that I am looping though the data because when I am debuging and put my mouse over "cell" at any point it brings back a value and not what cell i am on.

Can anyone help me with this?

Thanks!

Answer : VBA Looping through cells

Change:

    ActiveSheet.cell.Value = Left(cell, LResult) & " " & Right(cell, 2)

To:

    cell.Value = Left(cell, LResult) & " " & Right(cell, 2)

Kevin
Random Solutions  
 
programming4us programming4us