+ Reply to Thread
Results 1 to 3 of 3

Coping certain data sheet to sheet

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-03-2004
    Posts
    139

    Coping certain data sheet to sheet

    I am needing help in copying certain information from 1 sheet to another. I have attached a sample spreadsheet and I want to copy certain information from ACE spreadsheet - only columns A-D not the whole row to the completed tab into the designated lists based on the criteria listed on the spreadsheet. Not sure if this is the most efficient way so any suggestions would be greatly appreciated.

    Thanks in advance for your help and knowledge.
    Attached Files Attached Files
    Last edited by leem; 06-01-2010 at 02:16 PM.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Coping certain data sheet to sheet

    Hi again leem. Here is what I came up with:

    Public Sub leem2()
    
    Dim i, j, k, y, z As Integer
    Dim FNextrow As Long
    Dim MNextrow As Long
    Dim LNextrow As Long
    Dim SQtr As Date
    Dim EQtr As Date
    Dim lngDR As Long
    Dim blnBlank As Boolean
    
    Sheets("Completed").Activate
    SQtr = CDate(InputBox("Please enter the first date of the current quarter"))
    EQtr = CDate(InputBox("Please enter the final date of the current quarter"))
    With Sheets("ACE")
        For i = 3 To .Cells(3, 1).End(xlDown).Row
            'Checks if ACE tab, column F=16.  If true, transfer to Completed sheet.
            FNextrow = Sheets("Completed").Cells(Rows.Count, 1).End(xlUp).Row + 1
            If .Cells(i, 6).Value = 16 Then
                Sheets("Completed").Range(Cells(FNextrow, 1), Cells(FNextrow, 5)).Value = .Range(.Cells(i, 1), .Cells(i, 5)).Value
            End If
            'Checks if ACE tab, column E=PS or E=TS, with other conditions listed below.
            MNextrow = Sheets("Completed").Cells(Rows.Count, 7).End(xlUp).Row + 1
            blnBlank = False
            Select Case .Cells(i, 5).Value
                Case "PS"
                    For z = 7 To 37 Step 2
                        If .Cells(i, z).Value = 0 Then blnBlank = True
                    Next z
                    If blnBlank = False Then
                        Sheets("Completed").Range(Cells(MNextrow, 7), Cells(MNextrow, 11)).Value = .Range(.Cells(i, 1), .Cells(i, 5)).Value
                    End If
                Case "TS"
                    For y = 7 To 37 Step 2
                        If y <> 17 And y <> 19 And y <> 21 And y <> 33 And y <> 35 Then
                            If .Cells(i, y).Value = 0 Then blnBlank = True
                        End If
                    Next y
                    If blnBlank = False Then
                        Sheets("Completed").Range(Cells(MNextrow, 7), Cells(MNextrow, 11)).Value = .Range(.Cells(i, 1), .Cells(i, 5)).Value
                    End If
            End Select
            lngDR = .Cells(Rows.Count, "AL").End(xlUp).Row
            LNextrow = Sheets("Completed").Cells(Rows.Count, "M").End(xlUp).Row + 1
            For j = 7 To 37 Step 2
                If .Cells(i, j).Value > SQtr Then
                    If .Cells(i, j).Value < EQtr Then
                        Sheets("Completed").Range(Cells(LNextrow, 13), Cells(LNextrow, 17)).Value = .Range(.Cells(i, 1), .Cells(i, 5)).Value
                    End If
                End If
            Next j
        Next i
    End With
    
    End Sub
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Forum Contributor
    Join Date
    11-03-2004
    Posts
    139

    Thumbs up Re: Coping certain data sheet to sheet

    OMG! That is awesome and just works beautifully. I'm so amazed. I really thought I was asking for too much on that request. Thank you so very much! Brilliant, just brilliant!

+ 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