學(xué)習(xí)啦 > 學(xué)習(xí)電腦 > 工具軟件 > 辦公軟件學(xué)習(xí) > Excel教程 > Excel表格 > excel表格怎么設(shè)置提取數(shù)字

excel表格怎么設(shè)置提取數(shù)字

時(shí)間: 宇能938 分享

excel表格怎么設(shè)置提取數(shù)字

  當(dāng)我們在使用Excel進(jìn)行辦公的時(shí)候,我們可能會(huì)遇到一些數(shù)據(jù)需要進(jìn)行特殊提取的情況,下面學(xué)習(xí)啦小編馬上就告訴大家excel怎么提取數(shù)字吧,希望看完本教程的朋友都能學(xué)會(huì)并運(yùn)用起來。

  excel設(shè)置提取數(shù)字的辦法

  1、漢字在前,數(shù)字在后面的情形??梢杂肕ID,min, find三個(gè)函數(shù)來實(shí)現(xiàn)提取里面的數(shù)字。如圖:在B2輸入“=MID(A1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),20)”

  2 、把單元格里面所有的數(shù)字都提出來??梢允褂煤?。先打開VBA編輯器。工具——宏——visual basic 編輯器

  3、在編輯器里點(diǎn)擊插入——模塊。在模塊那里輸入如下代碼:

  復(fù)制內(nèi)容到剪貼板

  Function zzsz(xStr As String) As StringDim i As IntegerFor i = 1 To Len(xStr)If IsNumeric(Mid(xStr, i, 1)) Then zzsz = zzsz & Mid(xStr, i, 1)NextEnd Function

  4、回到工作表,在B2單元格那里輸入“=zzsz(A2)”。就可以用VBA把A2單元格里所有的數(shù)字都提取出來了,如圖所示。

  5、指定從第幾個(gè)數(shù)組提取開始。也就是說在不連續(xù)的那些數(shù)字中,從第幾次出現(xiàn)的數(shù)組開始提取。同樣在模塊那里輸入如下代碼:

  復(fù)制內(nèi)容到剪貼板

  Function GetNums(rCell As Range, num As Integer) As StringDim Arr1() As String, Arr2() As StringDim chr As String, Str As StringDim i As Integer, j As IntegerOn Error GoTo line1

  Str = rCell.TextFor i = 1 To Len(Str)chr = Mid(Str, i, 1)If (Asc(chr) < 48 Or Asc(chr) > 57) ThenStr = Replace(Str, chr, " ")End IfNext

  Arr1 = Split(Trim(Str))ReDim Arr2(UBound(Arr1))For i = 0 To UBound(Arr1)If Arr1(i) <> "" ThenArr2(j) = Arr1(i)j = j + 1End IfNext

  GetNums = IIf(num <= j, Arr2(num - 1), "")line1:End Function

  6、在回到單元格那里輸入“=Getnums(A3,2)”就可以提取第幾次出現(xiàn)的數(shù)組了,如圖所示。


猜你感興趣:

1.excel怎么提取數(shù)字

2.excel如何提取數(shù)字

3.excel表格中怎樣提取數(shù)字

4.Excel表格中如何在一串?dāng)?shù)字中提取幾位數(shù)字

5.怎么在excel中提取數(shù)字

2820478