|
求助:查找对应的文字所在列号,下面代码中当列中名称被强制换行时,不能找到对应列号,如“合同编号”,当所在列的“合同Chr(10)编号”名称为强制换行时,就无法得到“合同编号”所在的列号?
On Error Resume Next
Dim Co1, Co2, Co3, Co4, Co5, Co6 As String
Dim i As Byte, arr
arr = Array("合同编号", "签约日期", "合同名称", "合同额", "合同状态", "委托单位")
For i = 0 To 5
Set findcell = Range("2:2").Find("*" & arr(i) & "*", LookAt:=xlPart) '如果 是完全匹配 XLPART 改成XLWHOLE
If Not findcell Is Nothing Then FAJG = findcell.Column
If i = 0 Then Co1 = Split(Columns(FAJG).Address(0, 0), ":")(0)
If i = 1 Then Co2 = Split(Columns(FAJG).Address(0, 0), ":")(0)
If i = 2 Then Co3 = Split(Columns(FAJG).Address(0, 0), ":")(0)
If i = 3 Then Co4 = Split(Columns(FAJG).Address(0, 0), ":")(0)
If i = 4 Then Co5 = Split(Columns(FAJG).Address(0, 0), ":")(0)
If i = 5 Then Co6 = Split(Columns(FAJG).Address(0, 0), ":")(0)
Next
|
|