Results 1 to 11 of 11

Thread: Writing to a cell in a loop

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,709
    Location
    Try this
    Sub TimeChanger()
    Dim i as Long
    Dim LR As Long
    Dim X As String
    
    With Sheets("Sheet2")
       LR = .Cells(Rows.Count, "A").End(xlUp).Row
        For i = 4 To LR 
            X = .Cells(i, "A").Value2 
            If CInt(Left(X, 2)) > 24 Then _
           .Cells(i, "A")) = CStr(CInt(Left(X, 2)) Mod 24) & Mid(X, 3)
        Next
    End If
    End Sub
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  2. #2
    Quote Originally Posted by SamT View Post
    Try this
    Sub TimeChanger()
    Dim i as Long
    Dim LR As Long
    Dim X As String
    
    With Sheets("Sheet2")
       LR = .Cells(Rows.Count, "A").End(xlUp).Row
        For i = 4 To LR 
            X = .Cells(i, "A").Value2 
            If CInt(Left(X, 2)) > 24 Then _
           .Cells(i, "A")) = CStr(CInt(Left(X, 2)) Mod 24) & Mid(X, 3)
        Next
    End If
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •