我无法获取代码的最后一部分来读取数据列F到L中的最后一个单元格。它们上方会有空白单元格。然后粘贴到目标中的下一个可用行。
Sub addddddddddddddd()
'
' addddddddddddddd Macro
'
Dim LR As Long, LC As Integer
Dim lastRow As Long
Dim fNameAndPath As Variant, wb As Workbook
Dir "C:\User\keym\Desktop\Timecards"
fNameAndPath = Application.GetOpenFilename(FileFilter:="Excel Files (.), .", Title:="Select File To Be Opened")
If fNameAndPath = False Then Exit Sub
Set wb = Workbooks.Open(fNameAndPath)
wb.Activate
Range("D1").Select
Selection.Copy
Windows("Vacation-Sick-Summary.xls").Activate
Range("B10000").End(xlUp).Offset(1, -1).Select
ActiveSheet.Paste
wb.Activate
Range("F3:L3").Select
Selection.Copy
Windows("Vacation-Sick-Summary.xls").Activate
Range("B10000").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
For Each C In Selection
If C.Value = "" Then C.Value = "-"
C.HorizontalAlignment = xlCenter
Next C
wb.Activate
LR = Cells(Rows.Count, 1).End(xlUp).Row '?
LC = Cells(1, Columns.Count).End(xlToLeft).Column '?
Selection.Copy
wb.Close
Windows("Vacation-Sick-Summary.xls").Activate
ActiveSheet.Paste
For Each C In Selection
If C.Value = "" Then C.Value = "-"
C.HorizontalAlignment = xlCenter
Next C
wb.Activate
Range("D1").Select
Selection.Copy
Windows("Vacation-Sick-Summary.xls").Activate
Range("B10000").End(xlUp).Offset(1, -1).Select
ActiveSheet.Paste
wb.Activate
Range("F3:L3").Select
Selection.Copy
Windows("Vacation-Sick-Summary.xls").Activate
Range("B10000").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
For Each C In Selection
If C.Value = "" Then C.Value = "-"
C.HorizontalAlignment = xlCenter
Next C
wb.Activate
LR = Cells(Rows.Count, 1).End(xlUp).Row '?
LC = Cells(1, Columns.Count).End(xlToLeft).Column '?
Selection.Copy
wb.Close
Windows("Vacation-Sick-Summary.xls").Activate
ActiveSheet.Paste
For Each C In Selection
If C.Value = "" Then C.Value = "-"
C.HorizontalAlignment = xlCenter
Next C
答案 0 :(得分:1)
Range("B" & Rows.Count).End(xlUp).Offset(1, -1).Select
或您需要的任何一列。
在代码的最后一部分中:检查您正在复制的Selection
;还要检查您是要测试col A中的最后一行数据以及第1行的最后一列数据。