2016-07-15 14 views
0

ドロップダウンメニューのあるセルに基づいてインデックス(一致)を使用しているコードがあります。ユーザーが特定のセキュリティを選択すると、CUSIPが出力され、Bloombergの式を貼り付けてExcelにデータを出力します。Rangeクラスの削除メソッドが失敗しました

次に、テーブルを作成しますが、自動フィルタを使用してテーブルをフィルタリングし、フィルタ条件を満たす行を削除したいと思いますが、何らかの理由で機能していないようです。また、ユーザーがドロップダウンメニューをダブルクリックすると、セキュリティを検索してオートコンプリートすることができるように、ActiveXコントロールフォームのボタンを設定しました。

お願いします、ありがとうございます!

Sub INDEX_MATCH_CUSIP_TO_SHORTDESCRIPTION() 

Application.ScreenUpdating = False 
Application.Calculation = xlCalculationManual 

Sheets("Sheet4").Range("B3:E100").Delete 

Range("B2").Select 
test = Application.WorksheetFunction.Index(Sheets("DEX Spread Report (Corp)").Range("B7:B1600"),   Application.WorksheetFunction.Match(ActiveCell.Value, Sheets("DEX Spread Report (Corp)").Range("D7:D1600"), 0), 1) 
ActiveCell.Offset(1, 0).Value = test 

Application.ScreenUpdating = True 
Application.Calculation = xlCalculationAutomatic 

End Sub 

Sub BBRG_FORMULAS_FOR_SECURITY() 

Application.ScreenUpdating = False 
Application.Calculation = xlCalculationManual 

Dim CUSIPS As String 

    Sheets("Sheet4").Select 
    Range("B2").Select 

CUSIPS = ActiveCell.Offset(1, 0).Value 

ActiveCell.Offset(2, 0).Value = "=BDS(""" & CUSIPS & """ & ""& CUSIP"",""ALL_HOLDERS_PUBLIC_FILINGS"", ""STARTCOL=1"", ""ENDCOL=1"")" 
ActiveCell.Offset(2, 1).Value = "=BDS(""" & CUSIPS & """ & ""& CUSIP"",""ALL_HOLDERS_PUBLIC_FILINGS"", ""STARTCOL=6"", ""ENDCOL=8"")" 


Application.ScreenUpdating = True 
Application.Calculation = xlCalculationAutomatic 


End Sub 


Sub Create_Table_and_AutoFilter() 

Dim wksDest As Worksheet 
Dim LastRow As Long 
Dim rng  As Range 
Dim rngDelete As Range 

Sheets("Sheet4").Select 
Set wksDest = Worksheets("Sheet4") 

LastRow = Cells(Rows.Count, 2).End(xlUp).row 
LastRow1 = Cells(Rows.Count, 2).End(xlUp).row 

ActiveSheet.ListObjects.Add(xlSrcRange, Range(Cells(4, 2), Cells(LastRow, 5)), , xlYes).Name = "HoldersTable" 

With wksDest 
Set rng = Range(Cells(4, 2), Cells(LastRow1, 5)) 
rng.AutoFilter Field:=1, Criteria1:="<=1000" 
Set rngDelete = rng.SpecialCells(xlCellTypeVisible) 
rng.AutoFilter 
rngDelete.EntireRow.Delete 
End With 

End Sub 

答えて

0

あなたはおそらく次のスニペットでWith wksDestからEnd Withにコードを置き換えてみてくださいテーブルヘッダ

を削除しようとしている:

With wksDest.Range(Cells(4, 2), Cells(LastRow1, 5)) 
    .AutoFilter Field:=1, Criteria1:="<=1000" 
    If Application.WorksheetFunction.Subtotal(103, .Cells.Resize(,1)) > 1 Then .offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).EntireRow.Delete 
    .AutoFilter 
End With 
+0

私は(そして、.offsetにデバッグの問題を得ました1).resize .... – markos

+0

それは私に細胞が見つかりませんでした。私のテーブル内のセルが消えた.Autofilter Field:= 1 ... – markos

+0

正しい範囲は:wksDest.Range( "B4"、Cells(LastRow1、 "E"))である。 – markos

関連する問題