我正在尝试将两个单元格的值作为串联字符串传递给adata
数组,但是遇到了不匹配错误。如果仅使用aData = rData.Value2
,则宏可以正常工作。不确定如何解决此问题。
Set ws = x_bs
sSearchCol = "C"
sfind = ThisWorkbook.Names("dr_co").RefersToRange(1, 1)
Set rFindText = ws.Columns(sSearchCol).Find(sfind, ws.Cells(ws.Rows.Count, sSearchCol), xlValues, xlWhole, , xlNext)
If rFindText Is Nothing Then GoTo errHandler
Set rFindBlank = ws.Range(sSearchCol & 1, rFindText).Find(vbNullString, rFindText, xlValues, xlWhole, , xlPrevious)
Set rData = ws.Range(rFindBlank.Offset(1), rFindText.Offset(-1))
If rData.Cells.Count = 1 Then
ReDim aData(1 To 1, 1 To 1)
aData(1, 1) = rData.Value2 & " - " & rData.Offset(0, 2).Value2
Else
aData = rData.Value2 & " - " & rData.Offset(0, 2).Value2
End If