Hello. I have pretty decent experience with Excel but not with macros. The attached spreadsheet is a tool that I use in the field as I go from site to site. I want to use the "status" status column D to trigger a row copy to the adjacent "priorities" sheet (i.e. if the entry in column D = "incomplete" then copy entire row to "priorities" sheet. I found a macro on the web and plugged it in to the "full report" sheet and it pretty much does what I'm asking for, however, it' creating blank rows and other formatting issues in the "priorities" sheet. Any ideas? Thanks- Scott
try this modified maco:
Sub test() If ActiveSheet.Name <> "Full Report" Then Exit Sub LastRow = Range("D" & Rows.Count).End(xlUp).Row For Each Cell In Range("D8:D" & LastRow) If Cell = "Incomplete" Then Cell.EntireRow.Copy Sheets("Priorities").Cells(2, 1).Insert Shift:=xlDown End If Next Cell Application.CutCopyMode = False End Sub
sfoxbox,
Detach/open workbook GetIncomplete - sfoxbox - EF809567 - SDG10.xls and run macro GetIncomplete.
Have a great day,
Stan
stanleydgromjr
Windows Vista Business, Excel 2003 and 2007
If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
Thanks Stan. That works perfectly. However, rows 1 through 7 include generic data that I'd like to have at the top of the "priorities sheet and then have sorted data begin at row 8. Is there a way to do this? Thanks again for your help.
sfoxbox,
Your attached workbook did not have this information in worksheet Priorities.rows 1 through 7 include generic data that I'd like to have at the top of the "priorities sheet
Are these 7 rows coming from worksheet Full Report?
Or, should I just leave the first 7 rows of worksheet Priorities untouched?
Last edited by stanleydgromjr; 01-15-2012 at 06:47 PM.
Have a great day,
Stan
stanleydgromjr
Windows Vista Business, Excel 2003 and 2007
If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
Leaving the first 7 rows of the priorities sheet untouched would be sufficient.
sfoxbox,
Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).
Option Explicit Sub GetIncompleteV2() ' stanleydgromjr, 01/15/2012 ' http://www.excelforum.com/excel-programming/809567-macro-help-to-copy-row-from-one-spreadsheet-to-another.html Dim wF As Worksheet, wP As Worksheet Dim c As Range, firstaddress As String, nr As Long Application.ScreenUpdating = False Set wF = Worksheets("Full Report") Set wP = Worksheets("Priorities") nr = 8 With wF.Columns(4) Set c = .Find("Incomplete", LookIn:=xlValues, LookAt:=xlWhole) If Not c Is Nothing Then firstaddress = c.Address Do wF.Rows(c.Row).Copy wP.Range("A" & nr) nr = wP.Range("D" & Rows.Count).End(xlUp).Offset(1).Row Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address <> firstaddress End If End With wP.Activate Application.ScreenUpdating = True End Sub
Then run the GetIncompleteV2 macro.
Have a great day,
Stan
stanleydgromjr
Windows Vista Business, Excel 2003 and 2007
If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
Works great. One difference between this latest code and the previous code is if I run the macro twice, it copies the rows twice which is not desired. The first code would only copy the data once no matter how many times you ran the macro which is "fail safe". Is this a simple fix?
sfoxbox,
Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).
Option Explicit Sub GetIncompleteV3() ' stanleydgromjr, 01/15/2012 ' http://www.excelforum.com/excel-programming/809567-macro-help-to-copy-row-from-one-spreadsheet-to-another.html Dim wF As Worksheet, wP As Worksheet Dim c As Range, firstaddress As String, nr As Long, lr As Long Application.ScreenUpdating = False Set wF = Worksheets("Full Report") Set wP = Worksheets("Priorities") lr = wP.Cells(Rows.Count, "D").End(xlUp).Row If lr > 7 Then wP.Range("A8:J" & lr).Clear nr = 8 With wF.Columns(4) Set c = .Find("Incomplete", LookIn:=xlValues, LookAt:=xlWhole) If Not c Is Nothing Then firstaddress = c.Address Do wF.Rows(c.Row).Copy wP.Range("A" & nr) nr = wP.Range("D" & Rows.Count).End(xlUp).Offset(1).Row Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address <> firstaddress End If End With wP.Activate Application.ScreenUpdating = True End Sub
Then run the GetIncompleteV3 macro.
Have a great day,
Stan
stanleydgromjr
Windows Vista Business, Excel 2003 and 2007
If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
Awesome. Than man!
Hi Stanley,
Could you please help to add in the explanation beside the code?
This case is quite similar with mine. So I would like to try to modify it into my worksheet.
Thank![]()
sfoxbox,
Thanks for the feedback.
Come back anytime.
Have a great day,
Stan
stanleydgromjr
Windows Vista Business, Excel 2003 and 2007
If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
cyee,
Forum Rules
2. Don't post a question in the thread of another member -- start your own. If you feel it's particularly relevant, provide a link to the other thread.
Please create your own New Post, and then send me a Private Message with a link to your own New Post, and I will be happy to assist you.
In your own New Post:
To get the most precise answer, it is best to upload/attach a sample workbook (sensitive data scrubbed/removed/changed) that contains an example of your raw data on one worksheet, and on another worksheet your desired results.
The structure and data types of the sample workbook must exactly duplicate the real workbook. Include a clear and explicit explanation of your requirements.
To attach your workbook, scroll down and click on the Go Advanced button, then scroll down and click on the Manage Attachments button.
Have a great day,
Stan
stanleydgromjr
Windows Vista Business, Excel 2003 and 2007
If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
Hey Stan, it's me again. Over the past week or so I've had the chance to use the Excel spreadsheet and related macro you helped me with. By and large, it works just how I want it to but there is one more tweak I'd like to do if possible. I slightly modified the last code you sent (changed name of the "trigger word") so I've attached the latest copy of my spreadsheet so we can be on the same page. There are three worksheets in this workbook ("Full Report", "Prioritized Report" and "Executive Summary"). All of the data entry is done in the "Full Report" and once completed, your macro copies all rows that have a "No" in column D to the "Prioritized Report" spreadsheet. This function is working fine. However, the first 7 rows in the "Full Report" spreadsheet are basically "header rows" that should always be copied to the "Prioritized Report" spreadsheet and then the filtered data should begin at row 8. You last modified the macro to simply begin pasting at row 8 in the "Prioritized Sheet" which is working fine, but I'm having to do a manual cut and paste of the header rows into the "Prioritized Report" and the "Executive Summary". Can you adjust the macro to copy the first seven rows of the "Full Report" into both the "Prioritized Report" and the "Executive Summary" and then the filtered data into only the "Prioritized Report" beginning at row 8? I also want to preserve the existing function that does not duplicate data in any sheets if the macro is ran more than once. Your help is greatly appreciated. Thanks, Scott.
Last edited by sfoxbox; 01-26-2012 at 04:11 PM. Reason: Solved.
sfoxbox,
In your latest workbook, worksheet Full Report, range A1:J7, can be copied to worksheet Prioritized Report, range A1:J7.Can you adjust the macro to copy the first seven rows of the "Full Report" into both the "Prioritized Report" and the "Executive Summary"
But, worksheet Executive Summary, at present, only displays the data from worksheet Full Report, range A1:E3.
Do you want me to copy worksheet Full Report, range A1:J7, into worksheet Executive Summary?
Please explain in detail what this means.I also want to preserve the existing function that does not duplicate data in any sheets if the macro is ran more than once.
Have a great day,
Stan
stanleydgromjr
Windows Vista Business, Excel 2003 and 2007
If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks