+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25

Thread: Filter,copy and paste in excel

  1. #16
    Valued Forum Contributor vijay2482's Avatar
    Join Date
    03-03-2009
    Location
    Paris,France
    MS-Off Ver
    Excel 2003
    Posts
    244

    Re: Filter,copy and paste in excel

    Do I need to use this line of code in all the Filter codes or only in Filter1 sub?
    Set Thatwb = Workbooks.Open("C:\destination.xlsx")
    Thanks
    VIjay

    If you find any of the post useful to your question, please add to the contributor's reputation by clicking the blue scales icon in the blue bar of the post.

  2. #17
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    PA
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    926

    Re: Filter,copy and paste in excel

    Ok This shoud do it.

    ...
    Attached Files Attached Files
    Thank You, Mike

    Some Helpful Hints:

    1. New members please read & follow the Forum Rules
    2. Use Code Tags...Place[code]Before the first line and[/code] After the last line.
    3. If you are pleased with a solution mark your post SOLVED.
    4. Thank those who have help you by clicking the scales at the top right of the post.

    Here...

  3. #18
    Valued Forum Contributor vijay2482's Avatar
    Join Date
    03-03-2009
    Location
    Paris,France
    MS-Off Ver
    Excel 2003
    Posts
    244

    Re: Filter,copy and paste in excel

    Thanks once again...

    How should I use the code?
    Should I run the Filter1 sub on each sheet?
    VIjay

    If you find any of the post useful to your question, please add to the contributor's reputation by clicking the blue scales icon in the blue bar of the post.

  4. #19
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    PA
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    926

    Re: Filter,copy and paste in excel

    My Last post is a complete code example.

    You want to run the sub SubMyWorkbook from Module1 at the top which will loop through all the worksheets in the sample workbook. It will take care of all the other scripts.

    You can place a button on a worksheet to make things easier to run.

    If you want this option let me know I can do that as well.

    I may have forgotten one thing and that is are all the worksheets in the sample workbook the same? If not I will need to know what other worksheets you have in that workbook that are not the same as the others. I'm sure the data is different but if the layout are the same you should not have any issues.

    ...
    Thank You, Mike

    Some Helpful Hints:

    1. New members please read & follow the Forum Rules
    2. Use Code Tags...Place[code]Before the first line and[/code] After the last line.
    3. If you are pleased with a solution mark your post SOLVED.
    4. Thank those who have help you by clicking the scales at the top right of the post.

    Here...

  5. #20
    Valued Forum Contributor vijay2482's Avatar
    Join Date
    03-03-2009
    Location
    Paris,France
    MS-Off Ver
    Excel 2003
    Posts
    244

    Re: Filter,copy and paste in excel

    Thanks for the reply Mike.

    As you said, the data are not the same whereas the layout is the same for all the worksheets.
    Yes I would like to have a button added to the sheet.

    I ran the MyWorkbook sub and found that in the destination workbook, the filter from the 1st worksheet in the sample workbook is repeated 3 times, instead on one from each worksheet.

    Please find the attached workbook for reference.

    Thaks in advance.
    Attached Files Attached Files
    VIjay

    If you find any of the post useful to your question, please add to the contributor's reputation by clicking the blue scales icon in the blue bar of the post.

  6. #21
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    PA
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    926

    Re: Filter,copy and paste in excel

    I would hope you dont have anymore surprises...lol

    Here is a complete update with button.

    ...
    Attached Files Attached Files
    Thank You, Mike

    Some Helpful Hints:

    1. New members please read & follow the Forum Rules
    2. Use Code Tags...Place[code]Before the first line and[/code] After the last line.
    3. If you are pleased with a solution mark your post SOLVED.
    4. Thank those who have help you by clicking the scales at the top right of the post.

    Here...

  7. #22
    Valued Forum Contributor vijay2482's Avatar
    Join Date
    03-03-2009
    Location
    Paris,France
    MS-Off Ver
    Excel 2003
    Posts
    244

    Re: Filter,copy and paste in excel

    Thanks a lot Mike...

    Works perfect....

    Great job Mike...

    Thanks once again...
    VIjay

    If you find any of the post useful to your question, please add to the contributor's reputation by clicking the blue scales icon in the blue bar of the post.

  8. #23
    Valued Forum Contributor vijay2482's Avatar
    Join Date
    03-03-2009
    Location
    Paris,France
    MS-Off Ver
    Excel 2003
    Posts
    244

    Re: Filter,copy and paste in excel

    Mike

    I have changed the code accordingly and found that sheets 6 and 7 were not written.
    The column to filter for sheets 5,6 & 7 is column 9 backward from column P.
    code:
    For MySheet = 1 To 7
        Select Case (MySheet)
        Case Is = 1: B = 6
        Case Is = 2: B = 5
        Case Is = 3: B = 4
        Case Is = 4: B = 2
        Case Is = 5: B = 9 ' count backwards from Col P to get this number.
        Case Is = 6: B = 9 'count backwards from Col P to get this number.
        Case Is = 7: B = 9 'count backwards from Col P to get this number.
        End Select
    Please find the attached workbooks for your reference.
    Thaks in advance.
    Attached Files Attached Files
    VIjay

    If you find any of the post useful to your question, please add to the contributor's reputation by clicking the blue scales icon in the blue bar of the post.

  9. #24
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    PA
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    926

    Re: Filter,copy and paste in excel

    Ok Here are the changes Below:

    1st Change the current dim statment to this...
    Dim MySheet As Integer, B As Integer, i As Integer, MyNumber As String, BB As Integer
    2nd Change this pcs of code to this...
    For MySheet = 1 To 7
        Select Case (MySheet)
        Case Is = 1: B = 6
        Case Is = 2: B = 5
        Case Is = 3: B = 4
        Case Is = 4: B = 2
        Case Is = 5: B = 9: BB = 5
        Case Is = 6: B = 9: BB = 6
        Case Is = 7: B = 9: BB = 7
        End Select
    3rd Change this pcs of code to this...
    For Each cell In R
    If MySheet <= 4 Then
        If cell.Value > 0 Then
            MyNumber = cell.Value
            Exit For
        End If
    Else
        Select Case (BB)
            Case Is = 5: MyNumber = 28
            Case Is = 6: MyNumber = 39
            Case Is = 7: MyNumber = 16
        End Select
    Exit For
    End If
    Next cell
    And Last change this pcs near the bottom to this.
    For Each wks In Thatwb.Worksheets
    wks.Activate
    Range("A1:O1").Select
    ActiveWindow.Zoom = True
    Range("A1").Select
    Next wks
    You Know the drill by now, post back any issues.

    ...
    Thank You, Mike

    Some Helpful Hints:

    1. New members please read & follow the Forum Rules
    2. Use Code Tags...Place[code]Before the first line and[/code] After the last line.
    3. If you are pleased with a solution mark your post SOLVED.
    4. Thank those who have help you by clicking the scales at the top right of the post.

    Here...

  10. #25
    Valued Forum Contributor vijay2482's Avatar
    Join Date
    03-03-2009
    Location
    Paris,France
    MS-Off Ver
    Excel 2003
    Posts
    244

    Re: Filter,copy and paste in excel

    Works perfect...

    Thanks a lot Mike.
    VIjay

    If you find any of the post useful to your question, please add to the contributor's reputation by clicking the blue scales icon in the blue bar of the post.

+ 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.2.0