+ Reply to Thread
Results 1 to 3 of 3

Macro for copy data from one sheet to another based on drop-down value

Hybrid View

  1. #1
    Registered User
    Join Date
    03-09-2011
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    2

    Macro for copy data from one sheet to another based on drop-down value

    Hi,

    I want to be able to update my workbook when its opened by a macro copying all rows with a spesific dropdown value to the next sheet. This code has a debug i am not able to solve:

    Private Sub Workbook_Open()
    Dim i, LastRow
    
    LastRow = Sheets("01. Check list").Range("A100").End(xlUp).Row
    Sheets("02. Risk assesment").Range("A2:I500").ClearContents
    For i = 2 To LastRow
    If Sheets("01. Check list").Cells(i, "Risk").Value = "Yes" Then
    Sheets("01. Check list").Cells(i, "Risk").EntireRow.Copy Destination:=Sheets("02. Risk assesment").Range("No." & Rows.Count).End(xlUp).Offset(1)
    End If
    Next i
    End Sub
    A button in sheet1 doing the same would also be nice.

    Any tips? Thanks in advance for all feedback.
    Attached Files Attached Files

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524

    Re: Macro for copy data from one sheet to another based on drop-down value

    Column A is not Column "No." nor is column D column"Risk"

        Dim i, LastRow
    
        LastRow = Sheets("01. Check list").Range("A100").End(xlUp).Row
        Sheets("02. Risk assesment").Range("A2:I500").ClearContents
        For i = 2 To LastRow
            If Sheets("01. Check list").Cells(i, "D").Value = "Yes" Then
                Sheets("01. Check list").Cells(i, "D").EntireRow.Copy Destination:=Sheets("02. Risk assesment").Range("A" & Rows.Count).End(xlUp).Offset(1)
            End If
        Next i

  3. #3
    Registered User
    Join Date
    03-09-2011
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Macro for copy data from one sheet to another based on drop-down value

    Thanks Problem solved!

+ 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. [SOLVED] Macro to copy paste the data in one sheet to another based on the headers
    By sarajun_88 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-14-2016, 10:28 AM
  2. Macro to copy paste the data in one sheet to another based on the headers
    By sarajun_88 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-07-2016, 05:32 AM
  3. Macro to loop through drop down list and copy data to new sheet
    By mhenneman in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-29-2014, 04:11 PM
  4. [SOLVED] Macro to copy date to specific sheet based on data from another sheet.
    By RichTea88 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 08-09-2013, 11:28 AM
  5. Need a macro to copy data from one sheet to another based on condition.
    By kishoremcp in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-21-2013, 01:56 AM
  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 formula to end of data based in another sheet
    By Wazations in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-31-2012, 10:50 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