好的,有点麻烦。我正在做的是将上面的信息复制到空白单元格中。我也想添加一个单词“LAB”来旁边的coppied数据。代码如下。我一直在收到这个运行时错误。任何帮助都非常有用。
Sub FillColBlanks()
'fill blank cells in column with value above
Dim wks As Worksheet
Dim rng As Range
Dim lastRow As Long
Dim col As Long
Set wks = ActiveSheet
With wks
'col = ActiveCell.Column
col = .Range("C1").Column
Set rng = .UsedRange 'try to reset the lastcell
lastRow = ActiveSheet.Range("C" & Rows.Count).End(xlUp).Row
Set rng = Nothing
On Error Resume Next
Set rng = .Range(.Cells(2, col), .Cells(lastRow, col)) _
.Cells.SpecialCells(xlCellTypeBlanks)
On Error GoTo 0
If rng Is Nothing Then
MsgBox "No blanks found"
Exit Sub
Else
rng.FormulaR1C1 = "=R[-1]C&"" ""&""Lab"""
End If
'replace formulas with values
With .Cells(1, col).EntireColumn
.Value = .Value
End With
End With
End Sub