+ Reply to Thread
Results 1 to 7 of 7

Tricky Tricky episode 2!!!

  1. #1
    Registered User
    Join Date
    07-17-2006
    Posts
    54

    Tricky Tricky episode 2!!!

    I've been working on the code i received yesterday!

    That's what i have right now!

    U 442 2006-01-01 10:00:00 1
    U 442 2006-01-04 16:00:00 1 2
    U 442 2006-01-07 07:00:00 0
    U 442 2006-01-07 22:00:00 1
    U 442 2006-01-07 13:00:00 0

    That's what i want!

    U 442 2006-01-01 10:00:00 1
    U 442 2006-01-04 16:00:00 1 2
    U 442 2006-01-05
    U 442 2006-01-06
    U 442 2006-01-07 07:00:00 0
    U 442 2006-01-07 22:00:00 1
    U 442 2006-01-07 13:00:00 0

    That's the code i'm using!

    Sub test()
    Dim lLastRow As Long
    Dim lCurrRow As Long
    Dim vValue As Variant

    Application.ScreenUpdating = False

    With Worksheets("Sheet1")
    lLastRow = .Cells(.Rows.Count, 2).End(xlUp)

    For lCurrRow = lLastRow To 1 Step -1
    vValue = .Cells(lCurrRow, 7).Value
    If Len(vValue) > 0 And IsNumeric(vValue) Then
    .Cells(lCurrRow, 1).Resize(vValue, _
    1).EntireRow.Insert shift:=xlUp
    .Cells(lCurrRow, 6).Resize(vValue, _
    1).Value = 1440
    .Cells(lCurrRow, 1).Resize(vValue, _
    1).Value = .Cells(lCurrRow - 1, 1)
    .Cells(lCurrRow, 2).Resize(vValue, _
    1).Value = .Cells(lCurrRow - 1, 2) + 1
    End If
    Next lCurrRow
    End With

    Application.ScreenUpdating = True
    End Sub

    I cant find how make the new insert line go under, and i cant find how make the new dates fills up new blank cells! Need help! thanks!

  2. #2
    Bernie Deitrick
    Guest

    Re: Tricky Tricky episode 2!!!

    Try the macro below.

    HTH,
    Bernie
    MS Excel MVP

    Sub test()
    Dim lLastRow As Long
    Dim lCurrRow As Long
    Dim vValue As Variant

    Application.ScreenUpdating = False

    With Worksheets("Sheet1")
    lLastRow = .Cells(.Rows.Count, 2).End(xlUp).Row

    For lCurrRow = lLastRow To 2 Step -1
    If IsDate(Cells(lCurrRow - 1, 2).Value) And _
    IsDate(Cells(lCurrRow, 2).Value) Then
    If Cells(lCurrRow - 1, 2).Value <> Cells(lCurrRow, 2).Value - 1 Then
    Cells(lCurrRow, 2).EntireRow.Insert
    Cells(lCurrRow, 2).Value = Cells(lCurrRow + 1, 2).Value - 1
    Cells(lCurrRow, 1).Value = Cells(lCurrRow + 1, 1).Value
    lCurrRow = lCurrRow + 1
    End If
    End If
    Next lCurrRow
    End With

    Application.ScreenUpdating = True
    End Sub


    "mhax" <[email protected]> wrote in message
    news:[email protected]...
    >
    > I've been working on the code i received yesterday!
    >
    > That's what i have right now!
    >
    > U 442 2006-01-01 10:00:00 1
    > U 442 2006-01-04 16:00:00 1 2
    > U 442 2006-01-07 07:00:00 0
    > U 442 2006-01-07 22:00:00 1
    > U 442 2006-01-07 13:00:00 0
    >
    > That's what i want!
    >
    > U 442 2006-01-01 10:00:00 1
    > U 442 2006-01-04 16:00:00 1 2
    > U 442 2006-01-05
    > U 442 2006-01-06
    > U 442 2006-01-07 07:00:00 0
    > U 442 2006-01-07 22:00:00 1
    > U 442 2006-01-07 13:00:00 0
    >
    > That's the code i'm using!
    >
    > Sub test()
    > Dim lLastRow As Long
    > Dim lCurrRow As Long
    > Dim vValue As Variant
    >
    > Application.ScreenUpdating = False
    >
    > With Worksheets("Sheet1")
    > lLastRow = .Cells(.Rows.Count, 2).End(xlUp)
    >
    > For lCurrRow = lLastRow To 1 Step -1
    > vValue = .Cells(lCurrRow, 7).Value
    > If Len(vValue) > 0 And IsNumeric(vValue) Then
    > Cells(lCurrRow, 1).Resize(vValue, _
    > 1).EntireRow.Insert shift:=xlUp
    > Cells(lCurrRow, 6).Resize(vValue, _
    > 1).Value = 1440
    > Cells(lCurrRow, 1).Resize(vValue, _
    > 1).Value = .Cells(lCurrRow - 1, 1)
    > Cells(lCurrRow, 2).Resize(vValue, _
    > 1).Value = .Cells(lCurrRow - 1, 2) + 1
    > End If
    > Next lCurrRow
    > End With
    >
    > Application.ScreenUpdating = True
    > End Sub
    >
    > I cant find how make the new insert line go under, and i cant find how
    > make the new dates fills up new blank cells! Need help! thanks!
    >
    >
    > --
    > mhax
    > ------------------------------------------------------------------------
    > mhax's Profile: http://www.excelforum.com/member.php...o&userid=36450
    > View this thread: http://www.excelforum.com/showthread...hreadid=563411
    >




  3. #3
    Bernie Deitrick
    Guest

    Re: Tricky Tricky episode 2!!!

    Oops,

    Forgot about the doubled dates...


    Sub test()
    Dim lLastRow As Long
    Dim lCurrRow As Long
    Dim vValue As Variant

    Application.ScreenUpdating = False

    With Worksheets("Sheet1")
    lLastRow = .Cells(.Rows.Count, 2).End(xlUp).Row

    For lCurrRow = lLastRow To 2 Step -1
    If IsDate(Cells(lCurrRow - 1, 2).Value) And _
    IsDate(Cells(lCurrRow, 2).Value) Then
    If Cells(lCurrRow - 1, 2).Value <> Cells(lCurrRow, 2).Value - 1 And _
    Cells(lCurrRow - 1, 2).Value <> Cells(lCurrRow, 2).Value Then
    Cells(lCurrRow, 2).EntireRow.Insert
    Cells(lCurrRow, 2).Value = Cells(lCurrRow + 1, 2).Value - 1
    Cells(lCurrRow, 1).Value = Cells(lCurrRow + 1, 1).Value
    lCurrRow = lCurrRow + 1
    End If
    End If
    Next lCurrRow
    End With

    Application.ScreenUpdating = True
    End Sub

    HTH,
    Bernie
    MS Excel MVP


    "Bernie Deitrick" <deitbe @ consumer dot org> wrote in message
    news:[email protected]...
    > Try the macro below.
    >
    > HTH,
    > Bernie
    > MS Excel MVP
    >
    > Sub test()
    > Dim lLastRow As Long
    > Dim lCurrRow As Long
    > Dim vValue As Variant
    >
    > Application.ScreenUpdating = False
    >
    > With Worksheets("Sheet1")
    > lLastRow = .Cells(.Rows.Count, 2).End(xlUp).Row
    >
    > For lCurrRow = lLastRow To 2 Step -1
    > If IsDate(Cells(lCurrRow - 1, 2).Value) And _
    > IsDate(Cells(lCurrRow, 2).Value) Then
    > If Cells(lCurrRow - 1, 2).Value <> Cells(lCurrRow, 2).Value - 1 Then
    > Cells(lCurrRow, 2).EntireRow.Insert
    > Cells(lCurrRow, 2).Value = Cells(lCurrRow + 1, 2).Value - 1
    > Cells(lCurrRow, 1).Value = Cells(lCurrRow + 1, 1).Value
    > lCurrRow = lCurrRow + 1
    > End If
    > End If
    > Next lCurrRow
    > End With
    >
    > Application.ScreenUpdating = True
    > End Sub
    >
    >
    > "mhax" <[email protected]> wrote in message
    > news:[email protected]...
    >>
    >> I've been working on the code i received yesterday!
    >>
    >> That's what i have right now!
    >>
    >> U 442 2006-01-01 10:00:00 1
    >> U 442 2006-01-04 16:00:00 1 2
    >> U 442 2006-01-07 07:00:00 0
    >> U 442 2006-01-07 22:00:00 1
    >> U 442 2006-01-07 13:00:00 0
    >>
    >> That's what i want!
    >>
    >> U 442 2006-01-01 10:00:00 1
    >> U 442 2006-01-04 16:00:00 1 2
    >> U 442 2006-01-05
    >> U 442 2006-01-06
    >> U 442 2006-01-07 07:00:00 0
    >> U 442 2006-01-07 22:00:00 1
    >> U 442 2006-01-07 13:00:00 0
    >>
    >> That's the code i'm using!
    >>
    >> Sub test()
    >> Dim lLastRow As Long
    >> Dim lCurrRow As Long
    >> Dim vValue As Variant
    >>
    >> Application.ScreenUpdating = False
    >>
    >> With Worksheets("Sheet1")
    >> lLastRow = .Cells(.Rows.Count, 2).End(xlUp)
    >>
    >> For lCurrRow = lLastRow To 1 Step -1
    >> vValue = .Cells(lCurrRow, 7).Value
    >> If Len(vValue) > 0 And IsNumeric(vValue) Then
    >> Cells(lCurrRow, 1).Resize(vValue, _
    >> 1).EntireRow.Insert shift:=xlUp
    >> Cells(lCurrRow, 6).Resize(vValue, _
    >> 1).Value = 1440
    >> Cells(lCurrRow, 1).Resize(vValue, _
    >> 1).Value = .Cells(lCurrRow - 1, 1)
    >> Cells(lCurrRow, 2).Resize(vValue, _
    >> 1).Value = .Cells(lCurrRow - 1, 2) + 1
    >> End If
    >> Next lCurrRow
    >> End With
    >>
    >> Application.ScreenUpdating = True
    >> End Sub
    >>
    >> I cant find how make the new insert line go under, and i cant find how
    >> make the new dates fills up new blank cells! Need help! thanks!
    >>
    >>
    >> --
    >> mhax
    >> ------------------------------------------------------------------------
    >> mhax's Profile: http://www.excelforum.com/member.php...o&userid=36450
    >> View this thread: http://www.excelforum.com/showthread...hreadid=563411
    >>

    >
    >




  4. #4
    Registered User
    Join Date
    07-17-2006
    Posts
    54

    It's working but...

    Your code is working great, but it's not checking the value in colomn seven(G) as the previous code was doing (>> vValue = .Cells(lCurrRow, 7).Value
    >> If Len(vValue) > 0 And IsNumeric(vValue) Then)

    >> U 442 2006-01-01 10:00:00 1
    >> U 442 2006-01-04 16:00:00 1 2
    >> U 442 2006-01-07 07:00:00 0
    >> U 442 2006-01-07 22:00:00 1 1
    >> U 442 2006-01-09 13:00:00 0

    >> U 442 2006-01-01 10:00:00 1
    >> U 442 2006-01-04 16:00:00 1 2
    >> U 442 2006-01-05
    >> U 442 2006-01-06
    >> U 442 2006-01-07 07:00:00 0
    >> U 442 2006-01-07 22:00:00 1 1
    >> U 442 2006-01-08
    >> U 442 2006-01-09 13:00:00 0

    Have to look like this! I need like a fusion of the two codes! I have to look at the values (1,2,3, etc) in column 7, and insert that amount of row. But it has to also put the date missing!

    Thanks for the help! I really do appreciate!

    Mhax

    Quote Originally Posted by Bernie Deitrick
    Oops,

    Forgot about the doubled dates...


    Sub test()
    Dim lLastRow As Long
    Dim lCurrRow As Long
    Dim vValue As Variant

    Application.ScreenUpdating = False

    With Worksheets("Sheet1")
    lLastRow = .Cells(.Rows.Count, 2).End(xlUp).Row

    For lCurrRow = lLastRow To 2 Step -1
    If IsDate(Cells(lCurrRow - 1, 2).Value) And _
    IsDate(Cells(lCurrRow, 2).Value) Then
    If Cells(lCurrRow - 1, 2).Value <> Cells(lCurrRow, 2).Value - 1 And _
    Cells(lCurrRow - 1, 2).Value <> Cells(lCurrRow, 2).Value Then
    Cells(lCurrRow, 2).EntireRow.Insert
    Cells(lCurrRow, 2).Value = Cells(lCurrRow + 1, 2).Value - 1
    Cells(lCurrRow, 1).Value = Cells(lCurrRow + 1, 1).Value
    lCurrRow = lCurrRow + 1
    End If
    End If
    Next lCurrRow
    End With

    Application.ScreenUpdating = True
    End Sub

    HTH,
    Bernie
    MS Excel MVP


    "Bernie Deitrick" <deitbe @ consumer dot org> wrote in message
    news:[email protected]...
    > Try the macro below.
    >
    > HTH,
    > Bernie
    > MS Excel MVP
    >
    > Sub test()
    > Dim lLastRow As Long
    > Dim lCurrRow As Long
    > Dim vValue As Variant
    >
    > Application.ScreenUpdating = False
    >
    > With Worksheets("Sheet1")
    > lLastRow = .Cells(.Rows.Count, 2).End(xlUp).Row
    >
    > For lCurrRow = lLastRow To 2 Step -1
    > If IsDate(Cells(lCurrRow - 1, 2).Value) And _
    > IsDate(Cells(lCurrRow, 2).Value) Then
    > If Cells(lCurrRow - 1, 2).Value <> Cells(lCurrRow, 2).Value - 1 Then
    > Cells(lCurrRow, 2).EntireRow.Insert
    > Cells(lCurrRow, 2).Value = Cells(lCurrRow + 1, 2).Value - 1
    > Cells(lCurrRow, 1).Value = Cells(lCurrRow + 1, 1).Value
    > lCurrRow = lCurrRow + 1
    > End If
    > End If
    > Next lCurrRow
    > End With
    >
    > Application.ScreenUpdating = True
    > End Sub
    >
    >
    > "mhax" <[email protected]> wrote in message
    > news:[email protected]...
    >>
    >> I've been working on the code i received yesterday!
    >>
    >> That's what i have right now!
    >>
    >> U 442 2006-01-01 10:00:00 1
    >> U 442 2006-01-04 16:00:00 1 2
    >> U 442 2006-01-07 07:00:00 0
    >> U 442 2006-01-07 22:00:00 1
    >> U 442 2006-01-07 13:00:00 0
    >>
    >> That's what i want!
    >>
    >> U 442 2006-01-01 10:00:00 1
    >> U 442 2006-01-04 16:00:00 1 2
    >> U 442 2006-01-05
    >> U 442 2006-01-06
    >> U 442 2006-01-07 07:00:00 0
    >> U 442 2006-01-07 22:00:00 1
    >> U 442 2006-01-07 13:00:00 0
    >>
    >> That's the code i'm using!
    >>
    >> Sub test()
    >> Dim lLastRow As Long
    >> Dim lCurrRow As Long
    >> Dim vValue As Variant
    >>
    >> Application.ScreenUpdating = False
    >>
    >> With Worksheets("Sheet1")
    >> lLastRow = .Cells(.Rows.Count, 2).End(xlUp)
    >>
    >> For lCurrRow = lLastRow To 1 Step -1
    >> vValue = .Cells(lCurrRow, 7).Value
    >> If Len(vValue) > 0 And IsNumeric(vValue) Then
    >> Cells(lCurrRow, 1).Resize(vValue, _
    >> 1).EntireRow.Insert shift:=xlUp
    >> Cells(lCurrRow, 6).Resize(vValue, _
    >> 1).Value = 1440
    >> Cells(lCurrRow, 1).Resize(vValue, _
    >> 1).Value = .Cells(lCurrRow - 1, 1)
    >> Cells(lCurrRow, 2).Resize(vValue, _
    >> 1).Value = .Cells(lCurrRow - 1, 2) + 1
    >> End If
    >> Next lCurrRow
    >> End With
    >>
    >> Application.ScreenUpdating = True
    >> End Sub
    >>
    >> I cant find how make the new insert line go under, and i cant find how
    >> make the new dates fills up new blank cells! Need help! thanks!
    >>
    >>
    >> --
    >> mhax
    >> ------------------------------------------------------------------------
    >> mhax's Profile: http://www.excelforum.com/member.php...o&userid=36450
    >> View this thread: http://www.excelforum.com/showthread...hreadid=563411
    >>

    >
    >

  5. #5
    Registered User
    Join Date
    07-17-2006
    Posts
    54

    Fusion!

    Did you understand what i meant?

    Quote Originally Posted by Bernie Deitrick
    Oops,

    Forgot about the doubled dates...


    Sub test()
    Dim lLastRow As Long
    Dim lCurrRow As Long
    Dim vValue As Variant

    Application.ScreenUpdating = False

    With Worksheets("Sheet1")
    lLastRow = .Cells(.Rows.Count, 2).End(xlUp).Row

    For lCurrRow = lLastRow To 2 Step -1
    If IsDate(Cells(lCurrRow - 1, 2).Value) And _
    IsDate(Cells(lCurrRow, 2).Value) Then
    If Cells(lCurrRow - 1, 2).Value <> Cells(lCurrRow, 2).Value - 1 And _
    Cells(lCurrRow - 1, 2).Value <> Cells(lCurrRow, 2).Value Then
    Cells(lCurrRow, 2).EntireRow.Insert
    Cells(lCurrRow, 2).Value = Cells(lCurrRow + 1, 2).Value - 1
    Cells(lCurrRow, 1).Value = Cells(lCurrRow + 1, 1).Value
    lCurrRow = lCurrRow + 1
    End If
    End If
    Next lCurrRow
    End With

    Application.ScreenUpdating = True
    End Sub

    HTH,
    Bernie
    MS Excel MVP


    "Bernie Deitrick" <deitbe @ consumer dot org> wrote in message
    news:[email protected]...
    > Try the macro below.
    >
    > HTH,
    > Bernie
    > MS Excel MVP
    >
    > Sub test()
    > Dim lLastRow As Long
    > Dim lCurrRow As Long
    > Dim vValue As Variant
    >
    > Application.ScreenUpdating = False
    >
    > With Worksheets("Sheet1")
    > lLastRow = .Cells(.Rows.Count, 2).End(xlUp).Row
    >
    > For lCurrRow = lLastRow To 2 Step -1
    > If IsDate(Cells(lCurrRow - 1, 2).Value) And _
    > IsDate(Cells(lCurrRow, 2).Value) Then
    > If Cells(lCurrRow - 1, 2).Value <> Cells(lCurrRow, 2).Value - 1 Then
    > Cells(lCurrRow, 2).EntireRow.Insert
    > Cells(lCurrRow, 2).Value = Cells(lCurrRow + 1, 2).Value - 1
    > Cells(lCurrRow, 1).Value = Cells(lCurrRow + 1, 1).Value
    > lCurrRow = lCurrRow + 1
    > End If
    > End If
    > Next lCurrRow
    > End With
    >
    > Application.ScreenUpdating = True
    > End Sub
    >
    >
    > "mhax" <[email protected]> wrote in message
    > news:[email protected]...
    >>
    >> I've been working on the code i received yesterday!
    >>
    >> That's what i have right now!
    >>
    >> U 442 2006-01-01 10:00:00 1
    >> U 442 2006-01-04 16:00:00 1 2
    >> U 442 2006-01-07 07:00:00 0
    >> U 442 2006-01-07 22:00:00 1
    >> U 442 2006-01-07 13:00:00 0
    >>
    >> That's what i want!
    >>
    >> U 442 2006-01-01 10:00:00 1
    >> U 442 2006-01-04 16:00:00 1 2
    >> U 442 2006-01-05
    >> U 442 2006-01-06
    >> U 442 2006-01-07 07:00:00 0
    >> U 442 2006-01-07 22:00:00 1
    >> U 442 2006-01-07 13:00:00 0
    >>
    >> That's the code i'm using!
    >>
    >> Sub test()
    >> Dim lLastRow As Long
    >> Dim lCurrRow As Long
    >> Dim vValue As Variant
    >>
    >> Application.ScreenUpdating = False
    >>
    >> With Worksheets("Sheet1")
    >> lLastRow = .Cells(.Rows.Count, 2).End(xlUp)
    >>
    >> For lCurrRow = lLastRow To 1 Step -1
    >> vValue = .Cells(lCurrRow, 7).Value
    >> If Len(vValue) > 0 And IsNumeric(vValue) Then
    >> Cells(lCurrRow, 1).Resize(vValue, _
    >> 1).EntireRow.Insert shift:=xlUp
    >> Cells(lCurrRow, 6).Resize(vValue, _
    >> 1).Value = 1440
    >> Cells(lCurrRow, 1).Resize(vValue, _
    >> 1).Value = .Cells(lCurrRow - 1, 1)
    >> Cells(lCurrRow, 2).Resize(vValue, _
    >> 1).Value = .Cells(lCurrRow - 1, 2) + 1
    >> End If
    >> Next lCurrRow
    >> End With
    >>
    >> Application.ScreenUpdating = True
    >> End Sub
    >>
    >> I cant find how make the new insert line go under, and i cant find how
    >> make the new dates fills up new blank cells! Need help! thanks!
    >>
    >>
    >> --
    >> mhax
    >> ------------------------------------------------------------------------
    >> mhax's Profile: http://www.excelforum.com/member.php...o&userid=36450
    >> View this thread: http://www.excelforum.com/showthread...hreadid=563411
    >>

    >
    >

  6. #6
    Bernie Deitrick
    Guest

    Re: Tricky Tricky episode 2!!!

    I ignored the other conditional because your example did not include an extra column, and the
    results did not seem to depend on the entries in the column to the right of the date.

    HTH,
    Bernie
    MS Excel MVP


    "mhax" <[email protected]> wrote in message
    news:[email protected]...
    >
    > Did you understand what i meant?
    >
    > Bernie Deitrick Wrote:
    >> Oops,
    >>
    >> Forgot about the doubled dates...
    >>
    >>
    >> Sub test()
    >> Dim lLastRow As Long
    >> Dim lCurrRow As Long
    >> Dim vValue As Variant
    >>
    >> Application.ScreenUpdating = False
    >>
    >> With Worksheets("Sheet1")
    >> lLastRow = .Cells(.Rows.Count, 2).End(xlUp).Row
    >>
    >> For lCurrRow = lLastRow To 2 Step -1
    >> If IsDate(Cells(lCurrRow - 1, 2).Value) And _
    >> IsDate(Cells(lCurrRow, 2).Value) Then
    >> If Cells(lCurrRow - 1, 2).Value <> Cells(lCurrRow, 2).Value - 1 And _
    >> Cells(lCurrRow - 1, 2).Value <> Cells(lCurrRow, 2).Value Then
    >> Cells(lCurrRow, 2).EntireRow.Insert
    >> Cells(lCurrRow, 2).Value = Cells(lCurrRow + 1, 2).Value - 1
    >> Cells(lCurrRow, 1).Value = Cells(lCurrRow + 1, 1).Value
    >> lCurrRow = lCurrRow + 1
    >> End If
    >> End If
    >> Next lCurrRow
    >> End With
    >>
    >> Application.ScreenUpdating = True
    >> End Sub
    >>
    >> HTH,
    >> Bernie
    >> MS Excel MVP
    >>
    >>
    >> "Bernie Deitrick" <deitbe @ consumer dot org> wrote in message
    >> news:[email protected]...
    >> > Try the macro below.
    >> >
    >> > HTH,
    >> > Bernie
    >> > MS Excel MVP
    >> >
    >> > Sub test()
    >> > Dim lLastRow As Long
    >> > Dim lCurrRow As Long
    >> > Dim vValue As Variant
    >> >
    >> > Application.ScreenUpdating = False
    >> >
    >> > With Worksheets("Sheet1")
    >> > lLastRow = .Cells(.Rows.Count, 2).End(xlUp).Row
    >> >
    >> > For lCurrRow = lLastRow To 2 Step -1
    >> > If IsDate(Cells(lCurrRow - 1, 2).Value) And _
    >> > IsDate(Cells(lCurrRow, 2).Value) Then
    >> > If Cells(lCurrRow - 1, 2).Value <> Cells(lCurrRow, 2).Value - 1 Then
    >> > Cells(lCurrRow, 2).EntireRow.Insert
    >> > Cells(lCurrRow, 2).Value = Cells(lCurrRow + 1, 2).Value - 1
    >> > Cells(lCurrRow, 1).Value = Cells(lCurrRow + 1, 1).Value
    >> > lCurrRow = lCurrRow + 1
    >> > End If
    >> > End If
    >> > Next lCurrRow
    >> > End With
    >> >
    >> > Application.ScreenUpdating = True
    >> > End Sub
    >> >
    >> >
    >> > "mhax" <[email protected]> wrote in

    >> message
    >> > news:[email protected]...
    >> >>
    >> >> I've been working on the code i received yesterday!
    >> >>
    >> >> That's what i have right now!
    >> >>
    >> >> U 442 2006-01-01 10:00:00 1
    >> >> U 442 2006-01-04 16:00:00 1 2
    >> >> U 442 2006-01-07 07:00:00 0
    >> >> U 442 2006-01-07 22:00:00 1
    >> >> U 442 2006-01-07 13:00:00 0
    >> >>
    >> >> That's what i want!
    >> >>
    >> >> U 442 2006-01-01 10:00:00 1
    >> >> U 442 2006-01-04 16:00:00 1 2
    >> >> U 442 2006-01-05
    >> >> U 442 2006-01-06
    >> >> U 442 2006-01-07 07:00:00 0
    >> >> U 442 2006-01-07 22:00:00 1
    >> >> U 442 2006-01-07 13:00:00 0
    >> >>
    >> >> That's the code i'm using!
    >> >>
    >> >> Sub test()
    >> >> Dim lLastRow As Long
    >> >> Dim lCurrRow As Long
    >> >> Dim vValue As Variant
    >> >>
    >> >> Application.ScreenUpdating = False
    >> >>
    >> >> With Worksheets("Sheet1")
    >> >> lLastRow = .Cells(.Rows.Count, 2).End(xlUp)
    >> >>
    >> >> For lCurrRow = lLastRow To 1 Step -1
    >> >> vValue = .Cells(lCurrRow, 7).Value
    >> >> If Len(vValue) > 0 And IsNumeric(vValue) Then
    >> >> Cells(lCurrRow, 1).Resize(vValue, _
    >> >> 1).EntireRow.Insert shift:=xlUp
    >> >> Cells(lCurrRow, 6).Resize(vValue, _
    >> >> 1).Value = 1440
    >> >> Cells(lCurrRow, 1).Resize(vValue, _
    >> >> 1).Value = .Cells(lCurrRow - 1, 1)
    >> >> Cells(lCurrRow, 2).Resize(vValue, _
    >> >> 1).Value = .Cells(lCurrRow - 1, 2) + 1
    >> >> End If
    >> >> Next lCurrRow
    >> >> End With
    >> >>
    >> >> Application.ScreenUpdating = True
    >> >> End Sub
    >> >>
    >> >> I cant find how make the new insert line go under, and i cant find

    >> how
    >> >> make the new dates fills up new blank cells! Need help! thanks!
    >> >>
    >> >>
    >> >> --
    >> >> mhax
    >> >>

    >> ------------------------------------------------------------------------
    >> >> mhax's Profile:

    >> http://www.excelforum.com/member.php...o&userid=36450
    >> >> View this thread:

    >> http://www.excelforum.com/showthread...hreadid=563411
    >> >>
    >> >
    >> >

    >
    >
    > --
    > mhax
    > ------------------------------------------------------------------------
    > mhax's Profile: http://www.excelforum.com/member.php...o&userid=36450
    > View this thread: http://www.excelforum.com/showthread...hreadid=563411
    >




  7. #7
    Registered User
    Join Date
    07-17-2006
    Posts
    54

    yeah that's what i though

    ok yeah! But it has to insert rows only if there is a number corresponding in the column F (1,2,3,etc)! Do you have an idea for the fusion of my macro and yours?

    thanks!

    Quote Originally Posted by Bernie Deitrick
    I ignored the other conditional because your example did not include an extra column, and the
    results did not seem to depend on the entries in the column to the right of the date.

    HTH,
    Bernie
    MS Excel MVP


    "mhax" <[email protected]> wrote in message
    news:[email protected]...
    >
    > Did you understand what i meant?
    >
    > Bernie Deitrick Wrote:
    >> Oops,
    >>
    >> Forgot about the doubled dates...
    >>
    >>
    >> Sub test()
    >> Dim lLastRow As Long
    >> Dim lCurrRow As Long
    >> Dim vValue As Variant
    >>
    >> Application.ScreenUpdating = False
    >>
    >> With Worksheets("Sheet1")
    >> lLastRow = .Cells(.Rows.Count, 2).End(xlUp).Row
    >>
    >> For lCurrRow = lLastRow To 2 Step -1
    >> If IsDate(Cells(lCurrRow - 1, 2).Value) And _
    >> IsDate(Cells(lCurrRow, 2).Value) Then
    >> If Cells(lCurrRow - 1, 2).Value <> Cells(lCurrRow, 2).Value - 1 And _
    >> Cells(lCurrRow - 1, 2).Value <> Cells(lCurrRow, 2).Value Then
    >> Cells(lCurrRow, 2).EntireRow.Insert
    >> Cells(lCurrRow, 2).Value = Cells(lCurrRow + 1, 2).Value - 1
    >> Cells(lCurrRow, 1).Value = Cells(lCurrRow + 1, 1).Value
    >> lCurrRow = lCurrRow + 1
    >> End If
    >> End If
    >> Next lCurrRow
    >> End With
    >>
    >> Application.ScreenUpdating = True
    >> End Sub
    >>
    >> HTH,
    >> Bernie
    >> MS Excel MVP
    >>
    >>
    >> "Bernie Deitrick" <deitbe @ consumer dot org> wrote in message
    >> news:[email protected]...
    >> > Try the macro below.
    >> >
    >> > HTH,
    >> > Bernie
    >> > MS Excel MVP
    >> >
    >> > Sub test()
    >> > Dim lLastRow As Long
    >> > Dim lCurrRow As Long
    >> > Dim vValue As Variant
    >> >
    >> > Application.ScreenUpdating = False
    >> >
    >> > With Worksheets("Sheet1")
    >> > lLastRow = .Cells(.Rows.Count, 2).End(xlUp).Row
    >> >
    >> > For lCurrRow = lLastRow To 2 Step -1
    >> > If IsDate(Cells(lCurrRow - 1, 2).Value) And _
    >> > IsDate(Cells(lCurrRow, 2).Value) Then
    >> > If Cells(lCurrRow - 1, 2).Value <> Cells(lCurrRow, 2).Value - 1 Then
    >> > Cells(lCurrRow, 2).EntireRow.Insert
    >> > Cells(lCurrRow, 2).Value = Cells(lCurrRow + 1, 2).Value - 1
    >> > Cells(lCurrRow, 1).Value = Cells(lCurrRow + 1, 1).Value
    >> > lCurrRow = lCurrRow + 1
    >> > End If
    >> > End If
    >> > Next lCurrRow
    >> > End With
    >> >
    >> > Application.ScreenUpdating = True
    >> > End Sub
    >> >
    >> >
    >> > "mhax" <[email protected]> wrote in

    >> message
    >> > news:[email protected]...
    >> >>
    >> >> I've been working on the code i received yesterday!
    >> >>
    >> >> That's what i have right now!
    >> >>
    >> >> U 442 2006-01-01 10:00:00 1
    >> >> U 442 2006-01-04 16:00:00 1 2
    >> >> U 442 2006-01-07 07:00:00 0
    >> >> U 442 2006-01-07 22:00:00 1
    >> >> U 442 2006-01-07 13:00:00 0
    >> >>
    >> >> That's what i want!
    >> >>
    >> >> U 442 2006-01-01 10:00:00 1
    >> >> U 442 2006-01-04 16:00:00 1 2
    >> >> U 442 2006-01-05
    >> >> U 442 2006-01-06
    >> >> U 442 2006-01-07 07:00:00 0
    >> >> U 442 2006-01-07 22:00:00 1
    >> >> U 442 2006-01-07 13:00:00 0
    >> >>
    >> >> That's the code i'm using!
    >> >>
    >> >> Sub test()
    >> >> Dim lLastRow As Long
    >> >> Dim lCurrRow As Long
    >> >> Dim vValue As Variant
    >> >>
    >> >> Application.ScreenUpdating = False
    >> >>
    >> >> With Worksheets("Sheet1")
    >> >> lLastRow = .Cells(.Rows.Count, 2).End(xlUp)
    >> >>
    >> >> For lCurrRow = lLastRow To 1 Step -1
    >> >> vValue = .Cells(lCurrRow, 7).Value
    >> >> If Len(vValue) > 0 And IsNumeric(vValue) Then
    >> >> Cells(lCurrRow, 1).Resize(vValue, _
    >> >> 1).EntireRow.Insert shift:=xlUp
    >> >> Cells(lCurrRow, 6).Resize(vValue, _
    >> >> 1).Value = 1440
    >> >> Cells(lCurrRow, 1).Resize(vValue, _
    >> >> 1).Value = .Cells(lCurrRow - 1, 1)
    >> >> Cells(lCurrRow, 2).Resize(vValue, _
    >> >> 1).Value = .Cells(lCurrRow - 1, 2) + 1
    >> >> End If
    >> >> Next lCurrRow
    >> >> End With
    >> >>
    >> >> Application.ScreenUpdating = True
    >> >> End Sub
    >> >>
    >> >> I cant find how make the new insert line go under, and i cant find

    >> how
    >> >> make the new dates fills up new blank cells! Need help! thanks!
    >> >>
    >> >>
    >> >> --
    >> >> mhax
    >> >>

    >> ------------------------------------------------------------------------
    >> >> mhax's Profile:

    >> http://www.excelforum.com/member.php...o&userid=36450
    >> >> View this thread:

    >> http://www.excelforum.com/showthread...hreadid=563411
    >> >>
    >> >
    >> >

    >
    >
    > --
    > mhax
    > ------------------------------------------------------------------------
    > mhax's Profile: http://www.excelforum.com/member.php...o&userid=36450
    > View this thread: http://www.excelforum.com/showthread...hreadid=563411
    >

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1