+ Reply to Thread
Results 1 to 3 of 3

Finding value using loop

Hybrid View

  1. #1
    Registered User
    Join Date
    09-11-2007
    Posts
    41

    Finding value using loop

    Hello all,

    Can someone assist me with the following? I'm kind of new at this excel vba stuff. I will attach the spreadsheet. i'm trying to loop through the data and find a date value. There is a finish date column that i want to loop through and find the last row for that month and then insert a blank row.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    try this.

    Sub aaa()
      For i = Cells(Rows.Count, "G").End(xlUp).Row To 3 Step -1
        If Month(Cells(i, "G")) <> Month(Cells(i - 1, "G")) Then
          Cells(i, "A").EntireRow.Insert shift:=xlDown
          Cells(i, "A").Resize(1, 8).Interior.ColorIndex = 6
          Cells(i, "A").NumberFormat = "@"
          Cells(i, "A").Value = Format(Cells(i + 1, "G"), "mmmm yyyy")
        End If
      Next i
    End Sub
    you may want to make sure the data is sorted by column G before you action.


    rylo

  3. #3
    Registered User
    Join Date
    09-11-2007
    Posts
    41
    that works great! thank you for your help...

+ 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