我正在从外部来源导入原始数据,并将其粘贴到现有原始数据上。我有一个名为“ dataTbl”的表,当将新数据粘贴到现有数据上时需要更新该表。可以通过VBA完成吗?
我已经使用Excel宏记录器记录了以下代码,以使用新数据更改现有的“ dataTbl”。但是,当转换为VBA时,数据似乎不是动态的并且不能处理变量。也许还有另一种方法。
Option Explicit
Dim lastR As Long
Dim lastC As Long
Dim startCell As Range
Dim tblSource As Range
Dim wsSource As Worksheet
Dim wb As Workbook
Sub refresh()
'
'Refresh Excel table with newest Oracle data
'
Set wb = Workbooks("OTR_Dashboard")
Set wsSource = wb.Sheets("RawData")
With wsSource
Set startCell = Range("A1")
lastR = wsSource.Cells(Rows.Count, 1).End(xlUp).Row
lastC = wsSource.Cells(3, Columns.Count).End(xlToLeft).Column
End With
Set tblSource = wsSource.Range(wsSource.Cells(1, 1), wsSource.Cells(lastR, lastC))
Sheets("RawData").Range("A1").Select
Application.CutCopyMode = False
'ActiveWorkbook.Name("dataTbl").RefersToR1C1 = tblSource
ActiveWorkbook.Names("dataTbl").RefersToR1C1 = "=RawData!R1C1:R87671C28"
Application.CutCopyMode = False
Sheets("DASHBOARD").Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveWorkbook.RefreshAll
End Sub
注释掉的行(RefersToR1C1 = tblSource)给出错误消息“编译错误:参数数量错误或属性分配无效”。下面的一行没有动态数据,可以正常工作。
答案 0 :(得分:2)
用@Configuration
public class ApplicationConfig {
@Bean
@Scope(value = WebApplicationContext.SCOPE_SESSION, proxyMode = ScopedProxyMode.TARGET_CLASS)
public UserPrincipal sessionUserPrincipal() {
// not sure here the user does not exist at creation of bean
}
}
代替.RefersTo
结束了工作:
RefersToR1C1