Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Try this Sub ExtractData() Dim Rng As Range Dim lRows As Long Dim iCols As Integer 'Assuming a data download block beginning in A1 of active sheet Set Rng = Range("A1").CurrentRegion 'Get rows and column numbers With Rng lRows = .Rows.Count iCols = .Columns.Count 'add new col headers .Cells(1, iCols + 1).FormulaR1C1 = "user_ok" .Cells(1, iCols + 2).FormulaR1C1 = "date_ok" 'Insert formulas in other cells .Range(Cells(2, iCols + 1), Cells(lRows, iCols + 1)).FormulaR1C1 = _ "=OR((RC[-3]=""user01""),(RC[-3]=""user03""),(RC[-3]=""user04""),(RC[-3]=""u ser05""))" .Range(Cells(2, iCols + 2), Cells(lRows, iCols + 2)).FormulaR1C1 = _ "=OR((RC[-3]=DATE(2004,4,1)),(RC[-3]=DATE(2004,4,4)))" End With 'Reset rng Set Rng = Range("A1").CurrentRegion iCols = Rng.Columns.Count 'filter list and copy visible rows With Rng .AutoFilter Field:=iCols - 1, Criteria1:="TRUE" .AutoFilter Field:=iCols, Criteria1:="TRUE" .Cells.SpecialCells(xlCellTypeVisible).Copy 'Copy visible rows End With Sheets.Add Count:=1 ActiveSheet.Paste Application.CutCopyMode = False With Range("A1") .Select .CurrentRegion.Columns.AutoFit 'resize cols End With End Sub Regards Paul wrote in message ... Please help! I have a sheet(A) from colum A to colum D with field name like this: plan user date total There are about 500 records in this sheet(A). now I want to select records with date btw 04/01/04 to 04/03/04 and user name a user01, user05, user03, usero4. Is there anyway that I can program a VBA code to aumotically select those records and copy-paste them to sheet B? Your help is greatly appreciated !!!!! Meme |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Select records by month | New Users to Excel | |||
Randomly select records | Excel Discussion (Misc queries) | |||
Select records to new workbook | Excel Discussion (Misc queries) | |||
Randomly Select Records | Excel Worksheet Functions | |||
select records with a specific value | Excel Worksheet Functions |