在Excel中组合两列,并使用VBA将其导出为一列

我需要一些帮助。 我正在尝试构build一个Access表,我想根据date/时间进行sorting。 我从Excel工作表导出这些数据。 date在一个单元格中,但是时间在一列中。 访问表中的列是date,时间,坦克和评论。 我希望date列看起来像“mm / dd / yy hhmm”。 导出date时,我想在循环的每次运行中包含时间。 代码片段的一部分看起来像: .Fields("Date") = Range("B" & d "and "A" & r").Value ,其中“A”&r是时间列,其中r是行号,我怎么编程呢? 谢谢。

 Sub ExportU1() Sheets("Plant 1 WP Day").Select Dim cn As ADODB.Connection, rs As ADODB.Recordset, d, r As Long ' connect to the Access database Set cn = New ADODB.Connection cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _ "Data Source=U:\Night Sup\Production Report 2003 New Ver 5-28-10_KA.mdb;" ' open a recordset Set rs = New ADODB.Recordset rs.Open "UnitOneRouting", cn, adOpenKeyset, adLockOptimistic, adCmdTable d = 2 'row location of date r = 13 ' the start of Time, Tank and Comments row in the worksheet Do While Len(Range("A" & r).Formula) > 0 ' repeat until first empty cell in column A With rs .AddNew ' create a new record ' add values to each field in the record .Fields("Date") = Range("B" & d).Value .Fields("Time") = Range("A" & r).Value .Fields("Tank") = Range("C" & r).Value .Fields("Comments") = Range("D" & r).Value .Update ' stores the new record End With r = r + 1 ' next row Loop rs.Close Set rs = Nothing cn.Close Set cn = Nothing End Sub 

你有没有尝试像下面的串联?

 .Fields("Date") = Range("B" & d).Value & " " & Range("A" & r).Value