+ Reply to Thread
Results 1 to 6 of 6

VBA Macro to copy row values (not formulas) to another sheet based on cell data

  1. #1
    Registered User
    Join Date
    07-26-2012
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2013
    Posts
    15

    VBA Macro to copy row values (not formulas) to another sheet based on cell data

    I created a spreadsheet to list deliverable elements and assign them to different departments within my company. The User enters the data and selects a department that is responsible for the element on the Data sheet. The data is then copied to another sheet in the workbook based on the selected department by way of a macro that someone wrote for me.
    This has worked great until I started adding formulas to the data being copied. Is there a way to edit the following formula that will copy the row and only paste the values? I have tried a few things but my understanding of VBA is minimal at best.

    Private Sub Workbook_SheetActivate(ByVal Sh As Object)
    If Sh Is Sheet1 Or Sh Is Sheet3 Then Exit Sub
    Rows("13:" & Rows.Count).Clear
    For N = 13 To Sheet1.Cells(Rows.Count, 5).End(xlUp).Row
    If Sheet1.Cells(N, 5) = Sh.Name Then
    Sheet1.Rows(N).Copy Destination:=Sh.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).EntireRow
    End If
    Next N
    End Sub

    I've been looking around the forums for the answer but I haven't found anything that works.
    Thanks in advance!

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA Macro to copy row values (not formulas) to another sheet based on cell data

    Change

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-26-2012
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2013
    Posts
    15

    Re: VBA Macro to copy row values (not formulas) to another sheet based on cell data

    Fantastic! Thank you!

  4. #4
    Registered User
    Join Date
    07-26-2012
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2013
    Posts
    15

    Re: VBA Macro to copy row values (not formulas) to another sheet based on cell data

    Thank you for the answer but is there a way to clear the selection as part of the code? It works but when I switch back to the data sheet, the copied rows are still selected for copying.
    Thanks

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA Macro to copy row values (not formulas) to another sheet based on cell data

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    07-26-2012
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2013
    Posts
    15

    Re: VBA Macro to copy row values (not formulas) to another sheet based on cell data

    Thank you again!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro to copy and create data from 1 sheet to another, based on a cell value.
    By Dkstaurs in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-13-2016, 01:17 PM
  2. [SOLVED] Macro to Copy multiple rows from one sheet to another based on cell values
    By ParisG in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-13-2016, 03:07 AM
  3. Macro to copy formulas down based on row count from another sheet
    By kmrowlan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-08-2014, 01:07 PM
  4. [SOLVED] in need of macro to copy a row of data to another sheet based on text color of one cell
    By fredderf81 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-23-2013, 01:11 PM
  5. [SOLVED] Macro to Copy Data and Paste Values Based on cell criteria
    By Taislin in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-16-2012, 06:51 PM
  6. [SOLVED] Macro to Copy Data from one Sheet A to Sheet B based on value in cell on sheet A
    By scass in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-11-2012, 07:21 PM
  7. [SOLVED] Macro to copy formulas down based on row count from another sheet
    By kduschel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-21-2012, 06:51 AM

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