我是新手,我一直在尝试将单元格内容移动到一列。我在网上找到了一个代码并且工作正常但是当工作表有超过1000个内容时,它会出现“错误2029”。任何人都可以帮助我理解为什么会这样吗?
代码如下:
jobParametersBuilder.addString("fileName", request.getFileName());
jobExecution = jobLauncher.run(job, jobParametersBuilder.toJobParameters());
@Bean
public JobLauncher jobLauncher() {
SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
jobLauncher.setJobRepository(jobRepository());
jobLauncher.setTaskExecutor(asyncTaskExecutor());
return jobLauncher;
}
@Bean
@StepScope
public ItemWriter<Object> writer(@Value ("#{jobParameters['fileName']}"String fileName) {
JdbcBatchItemWriter<Object> writer = new JdbcBatchItemWriter<>();
writer.setItemSqlParameterSourceProvider(
new BeanPropertyItemSqlParameterSourceProvider<Object>());
writer.setSql(queryCollection.getquery());
writer.setDataSource(dataSource(fileName));
return writer;
}
它存储在我的PERSONAL.XLSB文件中并通过宏运行。当我在VBA项目中逐行运行时,它在
中给出了一个错误 Sub MakeOneColumn()
Dim vaCells As Variant
Dim vOutput() As Variant
Dim i As Long, j As Long
Dim lRow As Long
If TypeName(Selection) = "Range" Then
If Selection.Count > 1 Then
If Selection.Count <= Selection.Parent.Rows.Count Then
vaCells = Selection.Value
ReDim vOutput(1 To UBound(vaCells, 1) * UBound(vaCells, 2), 1 To 1)
For j = LBound(vaCells, 2) To UBound(vaCells, 2)
For i = LBound(vaCells, 1) To UBound(vaCells, 1)
If Len(vaCells(i, j)) > 0 Then
lRow = lRow + 1
vOutput(lRow, 1) = vaCells(i, j)
End If
Next i
Next j
Selection.ClearContents
Selection.Cells(1).Resize(lRow).Value = vOutput
End If
End If
End If
End Sub
表示不匹配错误。
这是测试文件的链接。
https://drive.google.com/open?id=0BwfUfQfWNeG5VVpIOFItcmdCSWs
答案 0 :(得分:0)
您的代码在我的计算机上正常运行。即使列的内容超过1,000,也不会发生错误。我假设您没有正确更改选择范围的名称,也没有选择所选范围&#34;范围&#34;当代码执行时。要更改新选定范围的引用,您可以在Excel 2010中的菜单公式►名称管理器中进行编辑。