![]() |
Copy cells from one sheet to another based on criteria
Hi,
I have accounting information on a sheet. One column is the account, the next one is the date of the movement, the next one is the amount, the last one is the comment. I would like to copy to another sheet the cells with the amount and the comment for one specified acount and dates included in one month. Do you have some code for this? I need help. thanks Nathalie |
Copy cells from one sheet to another based on criteria
You might have to change the sheet references to the actual sheet names, but
the code tested OK based on what you described. I suggest you test it on a copy of the file before you install it for permanent use in the actual file. Sub tract() Dim lr As Long, c As Range, acctVar As Variant lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row Set srcRng = ActiveSheet.Range("A2:A" & lr) acctVar = InputBox("Enter the account number to search.") For Each c In srcRng If c.Value = CLng(acctVar) Then Range("A" & c.Row & ":D" & c.Row).Copy _ Sheets(2).Range("A" & Sheets(2).Range("A65536"). _ End(xlUp).Row + 1) End If Next End Sub "Nathalie" wrote: Hi, I have accounting information on a sheet. One column is the account, the next one is the date of the movement, the next one is the amount, the last one is the comment. I would like to copy to another sheet the cells with the amount and the comment for one specified acount and dates included in one month. Do you have some code for this? I need help. thanks Nathalie |
All times are GMT +1. The time now is 05:23 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com