excel数据提取问题

Private Sub CommandButton1_Click()
    On Error Resume Next
    Dim myArray() As String
    Dim myPercent As String, rg As String, temp As String
    Dim i As Integer, j As Integer, k As Integer
    temp = ""
    Application.ScreenUpdating = False
    
    Range("W3:BH" & ActiveSheet.UsedRange.Rows.Count - 2).ClearContents
    Range("W3:BH" & ActiveSheet.UsedRange.Rows.Count - 2).NumberFormat = "0.00"
    For i = 3 To ActiveSheet.UsedRange.Rows.Count - 2
        temp = Cells(i, 22).Value
        myArray = Split(temp, ";")
        For j = 0 To UBound(myArray)
            rg = myArray(j)
            If InStr(rg, "%") > 0 Then
                If InStr(rg, ".") > 0 Then
                    myPercent = mydotNumber(rg) & "%"
                Else
                    myPercent = myNumber(rg) & "%"
                End If
                For k = 23 To 60
                    If Cells(1, k).Value = "" Then
                        Exit For
                    Else
                        If InStr(myArray(j), Cells(1, k).Value) > 0 Then
                            
                            Cells(i, k) = "=T" & i & "*" & myPercent
                            
                        End If
                    End If
                Next k
            End If
        Next j
    Next i
    
    Application.ScreenUpdating = True
    MsgBox ("完事了")
    
End Sub

Function myNumber(rg As String) '提取数字
    
    Set regx = CreateObject("VBScript.RegExp")
    With regx
        .Global = True
        .Pattern = "\D" '数字
        myNumber = .Replace(rg, "")
    End With
End Function

Function mydotNumber(rg As String)
    Set reg = CreateObject("vbscript.regexp")
    reg.Pattern = "(\d+\.\d+)"
    Set mh = reg.Execute(rg)
    If mh.Count Then
        mydotNumber = mh(0).Value
        Else: mydotNumber = ""
    End If
End Function




Private Sub CommandButton2_Click()
    For i = 3 To 54
        
        Range("V:V").Replace What:=Range("X" & i), Replacement:=Range("Y" & i), LookAt:=xlPart, SearchOrder:= _
            xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False, _
            FormulaVersion:=xlReplaceFormula2
        
    Next i
    
    
End Sub

各位大佬,目前提取的是v列数据,怎么改成提取w列数据。谢谢!

将v改为w试试

如果对你有帮助,可以点击我这个回答右上方的【采纳】按钮,给我个采纳吗,谢谢

您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~

如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632