Dim cat As Integer
For cat = 2 To last
Range("AB" & cat).Select
If Selection.Value = " " Then
ActiveCell.Offset(0, -2).Value = "-"
ActiveCell.Offset(0, -1).Value = "-"
ElseIf Selection.Value = "Address in local wording" Then
ActiveCell.Offset(0, -2).Value = "Customer"
ActiveCell.Offset(0, -1).Value = "Incomplete information or awaiting more info from customer"
ElseIf (Selection.Value = "hold to console" Or "Hold to console" Or "Allocated 14/12 and ship next day") Then
ActiveCell.Offset(0, -2).Value = "Depot"
ActiveCell.Offset(0, -1).Value = "Allotment delay"
ElseIf (Selection.Value = …Run Code Online (Sandbox Code Playgroud) 嗨,很抱歉,这几乎肯定是一个“ doh”时刻,但是我已经很长时间没有编码了,所以我有点生锈。
我有一个单元格值,当我尝试将其视为字符串时,我一直遇到类型不匹配的情况,但是CStr和测试IsNull等似乎没有帮助。感谢您的一些建议。
Set ClientTable = SourceBook.Sheets("Source Data").Range("extdata")
For Each rng1 In ClientTable.Columns(1).Cells
'if not first row (header row) and the customer name is matching the selected customer
If (i <> 0) And (rng1.Value = SourceBook.Sheets("Source Data").Range("C1")) Then
If Not IsNull(ClientTable.Columns(6).Cells.Offset(i, 0).Value) Then
MsgBox ClientTable.Columns(6).Cells.Offset(i, 0).Value ' type mismatch here
End If
With Sheets("Contacts").Range("A1")
.Offset(rowToWriteTo, 0).Value = ClientTable.Columns(6).Cells.Offset(i, 0).Value ' first name
.Offset(rowToWriteTo, 1).Value = ClientTable.Columns(2).Cells.Offset(i, 0).Value ' last name
.Offset(rowToWriteTo, 5).Value = ClientTable.Columns(3).Cells.Offset(i, 0).Value ' email
.Offset(rowToWriteTo, 6).Value = …Run Code Online (Sandbox Code Playgroud)