search范围如果空白提示用户Intup每个单元格

我有一个信息的范围,并希望检查之前,我保存它。 我有麻烦的方程提示用户哪个单元格是空的,然后提示他们input正确的信息。 我认为这是因为我将细胞定义为一个范围,或者我错过了其他的东西。 一旦popupinput框,我想通过偏移单元格到左边来告诉用户他们丢失了哪些数据。 左边的单元格是他们需要input的数据types(如date或名称)。 该偏移单元格不会显示在input框的消息中。

For Each CheckCell In Sheets("Sheet1").Range("J5:J17").Cells If Len(Trim(CheckCell.Value)) = 0 Then Cellcheck.Value = Application.InputBox("Please Enter Data for" & CheckCell.Offset(Rowoffset:=0, Columnoffset:=-1).Value, "Mission Info") End If Next CheckCell 

您的第三行应该是CheckCell.Value... ,而不是Cellcheck.Value...

 For Each CheckCell In Sheets("Sheet1").Range("J5:J17").Cells If Len(Trim(CheckCell.Value)) = 0 Then CheckCell.Value = Application.InputBox("Please Enter Data for " & CheckCell.Offset(Rowoffset:=0, Columnoffset:=-1).Value, "Mission Info") End If Next CheckCell 

纠正拼写错误

 Sub dural() For Each checkCell In Sheets("Sheet1").Range("J5:J17").Cells If Len(Trim(checkCell.Value)) = 0 Then mesage = "Please Enter Data for " & checkCell.Address(0, 0) checkCell.Value = Application.InputBox(Prompt:=mesage, Type:=1) End If Next checkCell End Sub 

更改types以符合您的要求。