我需要将工作表的第2行(导入设置)复制到另一个工作表的第2行(导入)然后我需要在导入设置工作表的下一行复制列LO并将其附加到第2行的末尾在导入工作表中,列L中的金额大于0.我需要继续将列LO从导入设置表上的下一行复制到导入表中,直到我复制98行,然后我需要复制整行导入设置工作表上的下一行到导入工作表的第3行,并继续如上,直到我达到98,然后再次重复处理。我知道我在这里会有什么工作,但我正在寻找一种更简单的方法,然后输入这么多代码。
Sub Create_invoice()
' Copies the first row of an invoice to the import template
Sheets("Import Setup").Select
Range("A2:O2").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Import").Select
Range("A2").Select
ActiveSheet.Paste
'Calls macro to copy additional Distributions up to 99
Call Copy_Distribution
End Sub
Sub Copy_Distribution()
'Copys distribution if invoice amount is not 0 up to 99
Sheets("Import Setup").Select
If Range("L3").Value > 0 Then
Range("L3:O3").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Import").Select
Range("P2").Select
ActiveSheet.Paste
End If
Sheets("Import Setup").Select
If Range("L4").Value > 0 Then
Range("L4:O4").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Import").Select
Range("T2").Select
ActiveSheet.Paste
End If
Sheets("Import Setup").Select
If Range("L5").Value > 0 Then
Range("L5:O5").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Import").Select
Range("X2").Select
ActiveSheet.Paste
End If
Sheets("Import Setup").Select
If Range("L6").Value > 0 Then
Range("L6:O6").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Import").Select
Range("AB2").Select
ActiveSheet.Paste
End If
Sheets("Import Setup").Select
If Range("L7").Value > 0 Then
Range("L7:O7").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Import").Select
Range("AF2").Select
ActiveSheet.Paste
End If
Sheets("Import Setup").Select
If Range("L8").Value > 0 Then
Range("L8:O8").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Import").Select
Range("AJ2").Select
ActiveSheet.Paste
End If
Sheets("Import Setup").Select
If Range("L9").Value > 0 Then
Range("L9:O9").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Import").Select
Range("AN2").Select
ActiveSheet.Paste
End If
Sheets("Import Setup").Select
If Range("L10").Value > 0 Then
Range("L10:O10").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Import").Select
Range("AR2").Select
ActiveSheet.Paste
End If
Sheets("Import Setup").Select
If Range("L11").Value > 0 Then
Range("L11:O11").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Import").Select
Range("AV2").Select
ActiveSheet.Paste
End If
Sheets("Import Setup").Select
If Range("L12").Value > 0 Then
Range("L12:O12").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Import").Select
Range("AZ2").Select
ActiveSheet.Paste
End If
Sheets("Import Setup").Select
If Range("L13").Value > 0 Then
Range("L13:O13").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Import").Select
Range("BD2").Select
ActiveSheet.Paste
End If
End Sub
答案 0 :(得分:1)
这是循环
$fb = new Facebook\Facebook(array(
'app_id' => $this->app_id,
'app_secret' => $this->app_secret,
'cookie' => true,
'status' => true,
'default_graph_version' => 'v2.10',
'http_client_handler' => 'curl', // can be changed to stream or guzzle
'persistent_data_handler' => 'session', // make sure session has started
));
$helper = $fb->getRedirectLoginHelper();
if (isset($_GET['state'])) {
$helper->getPersistentDataHandler()->set('state', $_GET['state']);
}
try {
// get access token
$accessToken = $helper->getAccessToken();
print_r($accessToken);
// save access token to persistent data store
$helper->getPersistentDataHandler()->set('access_token', $accessToken);
} catch (Exception $e) {
// error occured
echo 'Exception 1: ' . $e->getMessage() . '
';
}
// get stored access token
$accessToken = $helper->getPersistentDataHandler()->get('access_token');
if ($accessToken && !$accessToken->isExpired()) {
// set default access_token so we can use it in any requests
$fb->setDefaultAccessToken($accessToken);
}
我将范围替换为动态范围,从第3行替换为98,并使列的增量为4,因此它们不会重叠。 您可以尝试一下它是否适用于您的数据吗?