我有一个表:[捐赠Table.xlsm],由Access 2007导出,作为查询的结果;数据存储在" DonationDataQuery"片。我注意到所有数字字段都有一个绿色三角形 - 数字存储为文本。这是必要的,因为数据是由视障人士输入的,其中输入字段必须具有该字段的名称,默认为由音频阅读器读取。"
我有一个工作簿:[Pickup For Gen.xlsm],我在其中开发需要从" DonationDataQuery"中提取数据的代码。片。极度困难。现在只是尝试使用下面的代码修复数据字段。然而,当执行步骤到达"范围(" A1:O50")时。选择" (或其他代码中的任何" Range ...."语句),我收到错误1004 ...
任何人都想权衡?
Workbooks.Open Filename:="C:\Users\dads\Downloads\Donation Data.xlsm"
Worksheets("DonationDataQuery").Activate
'covert numbers brought over by Acess as text to numbers
Range("A1:O50").Select
With Selection
Selection.NumberFormat = "General"
.Value = .Value
End With
ActiveWindow.Close True
使用下面的建议,但遇到更多问题。我得到一个"运行时错误9下标超出范围。"然而范围看起来很精确。你能看到这个问题吗?
Dim wb1 As Workbook 'source
Dim ws1 As Worksheet 'source sheet Range "A1:W1000"
Dim wbp2 As Workbook 'target wb
Dim wsp2 As Worksheet 'target sheet Range "A100:W1100"
Dim prng, crng As Range
'set up the target range
Set wbp2 = ThisWorkbook
Set wsp2 = wbp2.Sheets("Sheet1")
Set prng = wsp2.Range("A100:W1100")
'set up the source range by opening the Company Data file
Set wb1 = Workbooks.Open("H:\Customer Database\Home 226\Company Data.xlsx")
Set ws1 = wb1.Sheets("Company_Data")
Set crng = ws1.Range("A1:W1000")
'now copy the source range into the target range
crng.Copy Destination:=prng

公司data.xlsx在错误时打开停靠点:设置ws1 = wb1.Sheets(" Company_Data")