对于副本,第一个结果仅不是整个列表

时间:2018-11-08 12:33:42

标签: excel vba

在我的Excel工作表“ XLSX”中,我有许多列。

首先,我搜索列标题“ Anwendung”和“ Profil-BenutzerId”。之后,我要将“ Anwendung”中的值为“ S6”的“ Profil-BenutzerId”中的所有字段复制到新的Excel工作表“ Rollen_Para”中。

我的代码正在复制满足这些条件的第一个结果,但我想复制整个列表。

Sheets("XLSX").Select

    Dim h As Long
    Dim i As Long
    Dim j As Long

    For h = 1 To 39
    For i = 1 To 39
    If Cells(19, h).Text = "Anwendung" And Cells(19, i).Text = "Profil-BenutzerId" Then
    For j = 20 To 1048576
    If Cells(j, h) = "S6" Then
    Cells(j, i).Select
    Selection.Copy
    Sheets("Rollen_Para").Select
    Cells(j - 18, 2).Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    Selection.Borders(xlEdgeLeft).LineStyle = xlNone
    Selection.Borders(xlEdgeTop).LineStyle = xlNone
    Selection.Borders(xlEdgeBottom).LineStyle = xlNone
    Selection.Borders(xlEdgeRight).LineStyle = xlNone
    Selection.Borders(xlInsideVertical).LineStyle = xlNone
    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    Selection.Borders(xlEdgeTop).LineStyle = xlNone
    Selection.Borders(xlEdgeBottom).LineStyle = xlNone
    Selection.Borders(xlEdgeRight).LineStyle = xlNone
    Selection.Borders(xlInsideVertical).LineStyle = xlNone
    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorDark1
        .TintAndShade = -0.149998474074526
        .PatternTintAndShade = 0
    End With
    End If
    Next
    End If
    Next
    Next
End Sub

1 个答案:

答案 0 :(得分:0)

您可以试试吗?您可以使用“查找”来避免大多数此类循环。我希望我有正确的方法。我已经忽略了与您的问题无关的边界,以后可以轻松添加。

from sklearn.kernel_approximation import Nystroem
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import Pipeline

K_train = anova_kernel(X_train)
clf = Pipeline([
    ('nys', Nystroem(kernel='precomputed', n_components=100)),
    ('lr', LogisticRegression())])
clf.fit(K_train, y_train)

K_test = anova_kernel(X_test, X_train)
preds = clf.predict(K_test)