问题:
我有一个工作簿,其中包含不同行中的大量信息。我想查找一个包含单词" description"的特定列。然后,首先,让用户知道列是否存在,没有被删除或更改等,向他们显示一个消息框。我成功地做到了。
现在,我需要抓住这一行 - 我在这里称它为rng1 - 然后我需要消除/清除它的旧命名法;那是1.1,1.2,2.3,......,3.3等。不是每一行中的其他文本,而只是这个命名法。
我被建议使用此代码的一部分(在2个消息框实例之后),但我不知道我做错了什么。我必须显示错误/成功消息框中是否存在单词' description'在列中(在这种情况下,列M或13)但我不能选择此行并清除它中的数字。
代码:
Sub CleanupDescription()
Dim Wb As Workbook
Dim ws As Worksheet
Dim rng1 As Range
Dim i As Integer
For i = 1 To 9999
Set Wb = ActiveWorkbook
Set ws = ActiveSheet
Set rng1 = ws.Range(“A1:Z1”).Find(“description”, ws.[a1], xlValues, xlWhole, , xlNext)
‘ This is to show an error if ‘description’ IS NOT present on A1:Z1
If Not rng1 Is Nothing Then
Else
MsgBox “’description’ column not found. Cannot proceed Padawan!”, vbCritical
End If
‘ This is to show a confirmation that ‘description’ IS present on A1:Z1
If rng1s Is Nothing Then
Else
MsgBox “’Description’ column found. Proceed Padawan!”, vbCritical
End If
If rng1 Is Nothing Then
For i = 1 To rng1
Select Case Mid(rng1, i, j)
Case 0 To 9
Case “ - “
Case “.”
Case “ “
Case Else
Exit For
End Select
Next
Range(“rng1” & j) = Mid(rng1, i, 1)
Next
End Sub
是工作表: https://dl.dropboxusercontent.com/u/4744355/aaaaaaa.xls
请注意,我已将所有文字转换为' aaa'因为隐私。