Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count if based on criteria within cells on another sheet --Viewpoint Excel Discussion (Misc queries) 1 August 21st 09 10:01 PM
Help: auto-copy entire rows from 1 sheet (based on cell criteria) to another sheet. bertbarndoor Excel Programming 4 October 5th 07 04:00 PM
Copy certain cells in a row to another sheet, based on certain val AM Excel Worksheet Functions 2 August 25th 07 04:38 AM
Copy rows to another sheet. Criteria = cells in column H is not em Henrik Excel Programming 0 May 10th 07 03:12 PM
Copy entire row to another sheet based on a criteria Brig Siton Excel Discussion (Misc queries) 3 August 7th 06 09:04 PM


All times are GMT +1. The time now is 08:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"