Results 1 to 45 of 45

Looping macro

Threaded View

DaSuPeR Looping macro 05-16-2008, 03:09 PM
stevebriz Can you post a sample of your... 05-16-2008, 04:29 PM
DaSuPeR Here is my .xls 05-16-2008, 04:44 PM
stevebriz I'm having trouble opening... 05-16-2008, 04:55 PM
DaSuPeR Try this one. 05-16-2008, 05:04 PM
  1. #1
    Registered User
    Join Date
    05-16-2008
    Posts
    31

    Looping macro

    I am trying to get data from Sheet Project_Pipeline Column D1, Match it to Row A1 in the DayView and continue until D1 is empty. I can only get it to copy and paste 1 section of data.

    Sub CopyDataToDayView()
    
        Dim LDate As String
        Dim LColumn As Integer
        Dim LFound As Boolean
        Do
        
        On Error GoTo Err_Execute
           'Retrieve date value to search for
        LDate = Sheets("Project_Pipeline").Range("D1").Value
           
       'Select Dayview
        Sheets("DayView").Select
        
        'Start at column B
        LColumn = 1
        LFound = False
        
        While LFound = False
        
            'Encountered blank cell in row 2, terminate search
            If Len(Cells(1, LColumn)) = 0 Then
                MsgBox "No matching date was found."
                Exit Sub
            
            'Found match in row 2
            ElseIf Cells(1, LColumn) = LDate Then
                            
                'Select values to copy from "Rolling Plan" sheet
                Sheets("Project_Pipeline").Select
                Range("C1").Select
                Selection.Copy
                
                'Paste onto "DayView" sheet
                Sheets("DayView").Select
                Cells(2, LColumn).Select
                Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
                    False, Transpose:=False
               LFound = True
                MsgBox "The data has been successfully copied."
            
            
            Else
            LColumn = LColumn + 1
                
            End If
          Sheets("Project_Pipeline").Select
          
           Loop Until IsEmpty(ActiveCell.Offset(0, 1))
        Exit Sub
        Wend
        
        On Error GoTo 0
          
       
    Err_Execute:
        MsgBox "An error occurred."
    End Sub
    Last edited by VBA Noob; 05-16-2008 at 03:18 PM.

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