Hi! I'm not sure if I'm in need of a macro or if this is something that can be done using functions.
But basically, I want to copy the entire columns A to D from Sheet1 into Sheet2. But only the rows that are NOT the value of 0.
I've got this function =Sheet1!A1. And then I just copy that into the other cells.
This has the advantage of automatic updates if the values in Sheet1 are changed.
But is it possible to edit the function to add an IF or something? Or would I need a macro to do this?
Here are a couple ways, Could use more information or example workbook.
Sub zero() Dim cell As Object Dim r As Range Dim lrow As Long Dim ThatRow As Long Application.ScreenUpdating = False ThatRow = Sheets(2).Range("A65536").End(xlUp).Row + 1 lrow = Range("A65536").End(xlUp).Row Set r = Range("A2:A" & lrow) For Each cell In r If cell.Value > 0 Then ''''This copies entire row to sheet 2 'cell.EntireRow.Copy Destination:=Sheets(2).Range("A" & Thatrow) 'or ''''This Copies A:D to sheet 2 Range(cell, cell.Offset(, 4)).Copy Destination:=Sheets(2).Range("A" & ThatRow) ThatRow = ThatRow + 1 End If Next cell Application.ScreenUpdating = True End Sub
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...
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks