我不知道怎么做,但是我需要允许以下代码运行,只要有一个满足这个条件的单元格。我尝试了一些功能,但没有一个功能正常。既然你的同伴,比我聪明,我希望你能帮助我。 唯一的要求是搜索条件必须以" 08"开头,该函数让我将文本转换为列。
Tks in Advance
Sub getDataProperly()
'
' Macro7 Macro
'
'
Cells.Find(What:="08*", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
Selection.TextToColumns Destination:=ActiveCell, DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 2), Array(2, 2), Array(10, 2), Array(15, 2), Array(19, 2), Array(27, 2), _
Array(31, 2), Array(39, 2), Array(43, 2), Array(51, 2), Array(55, 2), Array(63, 2), Array( _
67, 2), Array(75, 2), Array(79, 2), Array(87, 2), Array(91, 2), Array(99, 2), Array(103, 2), _
Array(111, 2), Array(115, 2), Array(123, 2), Array(127, 2), Array(135, 2), Array(139, 2), _
Array(147, 2), Array(151, 2), Array(159, 2), Array(163, 2), Array(171, 2), Array(175, 2), _
Array(183, 2), Array(187, 2), Array(195, 2), Array(199, 2), Array(207, 2), Array(211, 2), _
Array(219, 2), Array(223, 2), Array(231, 2), Array(235, 2), Array(243, 2), Array(247, 2), _
Array(255, 2), Array(259, 2), Array(267, 2), Array(271, 2), Array(279, 2), Array(283, 2), _
Array(290, 2), Array(295, 2), Array(302, 2), Array(307, 2), Array(315, 2), Array(319, 2), _
Array(327, 2), Array(331, 2), Array(339, 2), Array(343, 2), Array(351, 2), Array(355, 2), _
Array(363, 2), Array(367, 2), Array(375, 2), Array(379, 2), Array(387, 2), Array(391, 2), _
Array(399, 2), Array(403, 2), Array(411, 2), Array(415, 2), Array(423, 2), Array(427, 2), _
Array(435, 2), Array(439, 2), Array(447, 2), Array(451, 2), Array(459, 2), Array(463, 2), _
Array(471, 2), Array(475, 2), Array(483, 2), Array(487, 2), Array(495, 2), Array(499, 2), _
Array(507, 2), Array(511, 2), Array(519, 2), Array(523, 2), Array(531, 2), Array(535, 2), _
Array(543, 2), Array(547, 2), Array(555, 2), Array(559, 2), Array(567, 2), Array(571, 2), _
Array(579, 2), Array(583, 2), Array(591, 2), Array(595, 2), Array(603, 2), Array(607, 2), _
Array(615, 2), Array(619, 2), Array(627, 2), Array(631, 2), Array(639, 2), Array(643, 2), _
Array(651, 2)), TrailingMinusNumbers:=True
End Sub
答案 0 :(得分:0)
我会做类似以下的事情
Dim mySheet as WorkSheet
Set mySheet = wkb.sheets(mySheet)
Do Until mySheet.Cells(r,c) = ""
If InStr(mySheet.Cells(r,c), "08") = 1 Then
Call getDataProperly
End If
r = r + 1
Loop
这将使用mySheet
作为相关工作表的任何内容,并且这可以是动态的For each sheet in Workbook.Sheets
类型的方案。然后它在这种情况下循环遍历行,但是可以轻松地为列工作,直到它到达空单元格。如果需要更加定义的循环,可以使用For
循环使其运行一定数量的迭代。让您的呼叫运行的诀窍是If InStr(mySheet.Cells(r,c),"08") = 1
这样做的目的是查找“08”值,并且只有当匹配从您正在查看的单元格的第一个位置开始时才会getDataProperly
子工作