Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,574
Default why does this macro delete the value in A1?

I cobbled together the following macro, which does the following:
1) parses a 20,000 record table according to some criteria,
2) filters on those records for which the criteria are met, and
3) copies and pastes the filtered records to a new workbook.

My question is this: the number of rows in the source table will change
depending on what time of the month I download it from the server. How can I
adjust this macro to be dynamic, in terms of the number of rows over which
the filter criteria are applied?

Following is the code:

Sub ParseELR()
'
' ParseELR Macro
' Macro recorded 3/19/2007 by D Friedman
'

'
Range("A3").Select
If ActiveSheet.AutoFilterMode = True Then
Selection.AutoFilter
End If

If ActiveSheet.FilterMode = True Then
ActiveSheet.ShowAllData
End If

Range("T2").Select
ActiveCell.FormulaR1C1 = _
"=IF(AND(ISNUMBER(MATCH(LEFT(RC[-18],3),'[ELR expense account
identification.xls]Sheet1'!R2C1:R12C1,0)),ISNUMBER(MATCH(RC[-17],'[Frank''s
expense codes--GDCS and
non-GDCS.xls]Sheet1'!R2C1:R39C1,0))),""Extract"","""")"
Range("S2").Select
Selection.End(xlDown).Select
Range("T27355").Select
ActiveCell.FormulaR1C1 = "."
Range("T27354").Select
Selection.End(xlUp).Select
Range(Selection, Selection.End(xlDown)).Select
Range("T2:T27354").Select
Selection.FillDown
Selection.End(xlUp).Select
Selection.AutoFilter Field:=20, Criteria1:="Extract"
Selection.End(xlToLeft).Select
Selection.End(xlToLeft).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.SaveAs Filename:= _
"G:\NADC Finance\D Friedman\MONTHLY DATA SOURCES FOR
DB\ELR\2007\Mar\ELR Parsed.xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub


--
A hint to posters: Specific, detailed questions are more likely to be
answered than questions that provide no detail about your problem.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,574
Default why does this macro delete the value in A1?

Somehow I put the wrong subject line on this post. Sorry, ignore that. The
question I have is below.

Dave
--
A hint to posters: Specific, detailed questions are more likely to be
answered than questions that provide no detail about your problem.


"Dave F" wrote:

I cobbled together the following macro, which does the following:
1) parses a 20,000 record table according to some criteria,
2) filters on those records for which the criteria are met, and
3) copies and pastes the filtered records to a new workbook.

My question is this: the number of rows in the source table will change
depending on what time of the month I download it from the server. How can I
adjust this macro to be dynamic, in terms of the number of rows over which
the filter criteria are applied?

Following is the code:

Sub ParseELR()
'
' ParseELR Macro
' Macro recorded 3/19/2007 by D Friedman
'

'
Range("A3").Select
If ActiveSheet.AutoFilterMode = True Then
Selection.AutoFilter
End If

If ActiveSheet.FilterMode = True Then
ActiveSheet.ShowAllData
End If

Range("T2").Select
ActiveCell.FormulaR1C1 = _
"=IF(AND(ISNUMBER(MATCH(LEFT(RC[-18],3),'[ELR expense account
identification.xls]Sheet1'!R2C1:R12C1,0)),ISNUMBER(MATCH(RC[-17],'[Frank''s
expense codes--GDCS and
non-GDCS.xls]Sheet1'!R2C1:R39C1,0))),""Extract"","""")"
Range("S2").Select
Selection.End(xlDown).Select
Range("T27355").Select
ActiveCell.FormulaR1C1 = "."
Range("T27354").Select
Selection.End(xlUp).Select
Range(Selection, Selection.End(xlDown)).Select
Range("T2:T27354").Select
Selection.FillDown
Selection.End(xlUp).Select
Selection.AutoFilter Field:=20, Criteria1:="Extract"
Selection.End(xlToLeft).Select
Selection.End(xlToLeft).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.SaveAs Filename:= _
"G:\NADC Finance\D Friedman\MONTHLY DATA SOURCES FOR
DB\ELR\2007\Mar\ELR Parsed.xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub


--
A hint to posters: Specific, detailed questions are more likely to be
answered than questions that provide no detail about your problem.

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
delete a macro that isn't in macro list Jane Makinson Excel Discussion (Misc queries) 3 March 13th 06 01:10 PM
How can I delete a macro when the Delete button is not active? FCR Excel Worksheet Functions 0 March 9th 06 09:43 AM
How do i delete a macro in Excel 2003 when delete isn't highlight Abel Excel Discussion (Misc queries) 2 September 13th 05 04:09 AM
Macro to delete NoviceIan New Users to Excel 2 September 1st 05 01:03 PM
Delete a whole row using a macro LaurenceL Excel Discussion (Misc queries) 1 February 17th 05 08:49 PM


All times are GMT +1. The time now is 01:33 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"