excel 使用的内存不匹配

mec1mxoz  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(82)

我是相当新的这一点,并设法拼凑一些有用的代码,通过谷歌和帮助opn这个网站。
我目前被困在使用bullerr.或者也许有一个更好的方法来实现最终结果
我有一个电子表格与产品描述-在描述中有一个各种组合包sises.包1,包1,1包等.我已经写了一些代码,在那里我可以configur包的描述和大小表,并用它来填充一个字段与数字包大小. x1c 0d1xx 1c 1d 1x
代码工作正常,但它是匹配的10包在标题与包1,并把一个1在结束列
我已经尝试了各种组合的mosaR语法,但没有喜悦..我相信一定有一种方法来搜索一个完全匹配的字符串...
代码的工作方式,我想除了形式这一点!!我还没有复制整个宏只是这一块的代码.我感谢一如既往的任何帮助!

'Reset filter and 'Process PackSize not updated in filter process
  PackListWs.Activate
  ApdTbl.AutoFilter.ShowAllData
   PLCount = 
PackTbl.AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count
  SizeCount = 
SizeTbl.AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count
  AmzDataWs.Activate
  For i = 6 To ApdCount

  If Sheets("DATA - Product Validation").Range("i" & i).Value = "" Then
    If Sheets("DATA - Product Validation").Range("g" & i).Value <> "" Then
  k = 2
  For k = 2 To PLCount
  sc = 2
  For sc = 2 To SizeCount

  
    PackSize = PackListWs.Range("e" & sc).Value
    PackFilter = PackListWs.Range("c" & k).Value
    
    
    PackFilter = Replace((PackFilter), "*", PackSize)
   PackFilter = "*" & PackFilter & "*"
    
    Application.StatusBar = "Processing Amazon Pack Sizes without brackets -  " & 
PackFilter
    StrToChk = AmzDataWs.Range("g" & i).Value

If InStr(1, (StrToChk), (PackFilter), vbTextCompare) > 0 Then
AmzDataWs.Range("i" & i) = PackSize
Else
GoTo NoUpdate2
End If
NoUpdate2:
    Next sc
    Next k
    End If
    End If

Next i

字符串

idv4meu8

idv4meu81#

这里有一些尝试:

Sub Doit()

    Dim sTest As String
    sTest = "qwerwqerqwerweqrqwer (Pack of 10)"
    
    
    Dim iLocate_PackOf As Long
    Dim sPackOf As String
    Dim aPackOf() As String
    Dim sCount As String
    Dim iCount As Long
    
    sTest = LCase(sTest) ' Set to lowercase
    sTest = Trim(Replace(sTest, ")", " ")) ' replace any right penrens with space, then trim
    iLocate_PackOf = InStr(1, sTest, "pack of ")
    
    iCount = 0
    
    If iLocate_PackOf > 0 Then
    
        sPackOf = Right(sTest, Len(sTest) - iLocate_PackOf) ' Extract "pack of XX"
        aPackOf = Split(sPackOf, " ") ' Split "pack of XX" into array
        sCount = aPackOf(UBound(aPackOf)) ' Get last element, XX
        
        If IsNumeric(sCount) Then ' If it's a number then get count.
            iCount = CLng(sCount)
        End If
    End If

End Sub

字符串

相关问题