Results 1 to 9 of 9

Issue with Copying from one sheet to another

Threaded View

elthznd901 Issue with Copying from one... 04-30-2020, 03:33 PM
xladept Re: Issue with Copying from... 04-30-2020, 03:50 PM
elthznd901 Re: Issue with Copying from... 04-30-2020, 03:55 PM
xladept Re: Issue with Copying from... 04-30-2020, 04:10 PM
elthznd901 Re: Issue with Copying from... 04-30-2020, 04:53 PM
Barieq Re: Issue with Copying from... 04-30-2020, 06:55 PM
vcoolio Re: Issue with Copying from... 04-30-2020, 10:30 PM
elthznd901 Re: Issue with Copying from... 05-01-2020, 01:52 PM
vcoolio Re: Issue with Copying from... 05-01-2020, 10:36 PM
  1. #1
    Registered User
    Join Date
    04-30-2020
    Location
    Colorado USA
    MS-Off Ver
    2016
    Posts
    4

    Issue with Copying from one sheet to another

    Hello,

    Thanks in advance to whoever may have an idea. I have found some code on here that I was trying to modify for my spreadsheet to do something similar. I do not know code very well at all as a heads up.

    Basically I have a source work sheet called "Worksheet" and a destination worksheet called "BOM". If the QTY(located in row c) in the source worksheet is greater than 0 I want it to copy those specific rows and particular cells to the BOM worksheet when I click the button.

    This does copy the correct cells, but it copies all rows even if it doesnt have any QTY at all.

    Any thoughts?


    Sub Button1_Click()
    
    Dim sws As Worksheet, dws As Worksheet
    Dim slr As Long, dlr As Long
    Set sws = Sheets("Worksheet")
    Set dws = Sheets("BOM")
    slr = sws.Cells(Rows.Count, 1).End(xlUp).Row
    dlr = dws.Cells(Rows.Count, 2).End(xlUp).Row
    If dlr > 2 Then dws.Range("A3:G" & dlr).EntireRow.Clear
    sws.AutoFilterMode = False
    With sws.Rows(26)
        .AutoFilter field:=3, Criteria1:=">0"
    End With
    sws.Range("C26:C340" & slr).SpecialCells(xlCellTypeVisible).Copy dws.Range("A3")
    sws.Range("D26:D340" & slr).SpecialCells(xlCellTypeVisible).Copy dws.Range("B3")
    sws.Range("E26:E340" & slr).SpecialCells(xlCellTypeVisible).Copy dws.Range("C3")
    sws.Range("F26:F340" & slr).SpecialCells(xlCellTypeVisible).Copy dws.Range("D3")
    sws.Range("G26:G340" & slr).SpecialCells(xlCellTypeVisible).Copy dws.Range("E3")
    sws.AutoFilterMode = False
    dws.Columns("C").AutoFit
    MsgBox "Finished.", vbInformation
    End Sub
    Last edited by AliGW; 05-01-2020 at 01:55 PM. Reason: Solved tag added - no need to edit thread title or add solved to post. Thanks.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Issue in Copying Row to a New Sheet
    By lateniteNC1 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-12-2017, 12:33 PM
  2. Replies: 0
    Last Post: 05-09-2017, 11:58 AM
  3. copying sheet issue caused by hidden sheets in fhile
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-19-2017, 10:37 AM
  4. Target Cell location issue while copying entire sheet by Macro
    By AnimeshRoy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-04-2016, 12:41 PM
  5. Copying Data from one sheet to another... issue using End(xldown) in subroutine
    By joe31623 in forum Excel Programming / VBA / Macros
    Replies: 37
    Last Post: 02-17-2016, 05:48 PM
  6. [SOLVED] Issue with Copying data to a New Sheet After Filtering.
    By AparnaSriram in forum Excel General
    Replies: 10
    Last Post: 11-16-2012, 04:17 AM
  7. Excel 2007 : issue copying sheet w/ names in calculations
    By BobbyD1120 in forum Excel General
    Replies: 3
    Last Post: 01-23-2011, 03:58 PM

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