我有两张表,第1张和第2张。 如果T在表2中包含1,我正在查看sheet1的列T并粘贴整行。 该代码运行良好,但它将sheet2中的结果粘贴到sheet1的同一行中。 这导致行之间的空白。任何人都可以建议,我应该改变我的代码,以便我按顺序得到它们没有任何空行。 另外,如何将第1行中的页眉从第1页复制到第2页?
Sub Test()
For Each Cell In Sheets(1).Range("T:T")
If Cell.Value = "1" Then
matchRow = Cell.Row
Rows(matchRow & ":" & matchRow).Select
Selection.Copy
Sheets(2).Select
ActiveSheet.Rows(matchRow).Select
ActiveSheet.Paste
Sheets(1).Select
End If
Next
End Sub
答案 0 :(得分:2)
无需使用private final EventListener vungleEventListener = new EventListener() {
@Override
public void onVideoView(boolean arg0, int arg1, int arg2) {
if (arg0) {
addHint(getResources().getInteger(R.integer.videoHints));
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(context, "5 Hints added", Toast.LENGTH_SHORT).show();
}
});
} else {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(context, "Watch Complete video to add hints", Toast.LENGTH_SHORT).show();
}
});
}
}
@Override
public void onAdUnavailable(final String arg0) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(context, arg0, Toast.LENGTH_LONG).show();
}
});
}
@Override
public void onAdStart() {
}
@Override
public void onAdEnd(boolean arg0) {
initialiseVungle();
}
@Override
public void onAdPlayableChanged(boolean arg0) {
Toast.makeText(context, "You cannot play any ad now. Try after sometime", Toast.LENGTH_LONG).show();
}
};
和Select
复制粘贴,只会减慢代码的运行时间。
Selection
答案 1 :(得分:2)
不适合积分
道歉,但我无法阻止自己发布答案。当我看到有人想用一种低劣的做事方式时,我很痛苦:(
我不赞成循环。与Autofilter相比,它非常慢。
如果您仍然想要使用循环,那么您可以通过不复制循环中的行但最后在 ONE GO ...中加快速度...
此外,如果您不喜欢危险地生活,那么总是完全限定您的对象,否则您可能最终会复制错误的行。
Option Explicit
Sub Sample()
Dim wsI As Worksheet, wsO As Worksheet
Dim lRow As Long, i As Long, r As Long
Dim copyRng As Range
Set wsI = Sheet1: Set wsO = Sheet2
wsO.Cells.Clear
'~~> first available row in sheet2
r = 2
With wsI
lRow = .Range("T" & .Rows.Count).End(xlUp).Row
'~~> Copy Headers
.Rows(1).Copy wsO.Rows(1)
For i = 1 To lRow
If .Range("T" & i).Value = 1 Then
If copyRng Is Nothing Then
Set copyRng = .Rows(i)
Else
Set copyRng = Union(copyRng, .Rows(i))
End If
End If
Next i
End With
If Not copyRng Is Nothing Then copyRng.Copy wsO.Rows(r)
End Sub