国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開(kāi)發(fā) > 綜合 > 正文

EXCEL下使用MATCH函數(shù)碰到的問(wèn)題

2024-07-21 02:24:00
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

sub usematch()
   dim s_p as string, e_p as string
   dim num as integer
    num = 0
    for each m in range("a:a")
      if m.value <> "" then
        num = num + 1
      else
        exit for
      end if
    next m
    erange = "b" & num
    erange = "b2:" & erange
    n = 1
    a = 2
    currange = "b" & a
    cells.select
    selection.sort key1:=range("a2"), order1:=xlascending, key2:=range("b2") _
        , order2:=xlascending, header:=xlguess, ordercustom:=1, matchcase:= _
        false, orientation:=xltoptobottom, sortmethod:=xlpinyin, dataoption1:= _
        xlsortnormal, dataoption2:=xlsortnormal
    columns("a:a").select
    selection.insert shift:=xltoright '最左插入一列
    set curcell = worksheets(sheets(1).name).range(currange)
    for each m in range(erange)
      on error goto errorhandler
      if m.offset(0, -1).value <> "" then goto mynext
      if m.offset(0, 1).value = "" then goto mynext    '當(dāng)前單元格左不為空/右單元格內(nèi)容為空則轉(zhuǎn)
      s_p = m.value: e_p = m.offset(0, 1).value
   
      pos = application.worksheetfunction.match(e_p, worksheets(1).range(erange), 0) '查找終點(diǎn)在起點(diǎn)列出現(xiàn)的行數(shù)
      if pos = "" then
        curcell.offset(0, -1).value = "no"
        goto mynext              '若沒(méi)有找到則設(shè)為"no"
      end if
thenext:
      position = "b" & trim(str(pos))                   '定位到所在單元格
      if range(position).offset(0, 1).value = s_p then 
        if range(position).offset(0, -1) = "" then       '若符合條件則在對(duì)應(yīng)記錄前標(biāo)記
          curcell.offset(0, -1).value = n & ".a"
          range(position).offset(0, -1).value = n & ".b"
          n = n + 1
        else
          curcell.offset(0, -1).value = "no"
        end if
       
        else
        if range(position).offset(1, 0).value = e_p then 
          pos = pos + 1
          goto thenext
        else
          curcell.offset(0, -1).value = "no"
        end if
      end if
   myvar = 0

mynext:
   a = a + 1
    currange = "b" & a
    set curcell = worksheets(sheets(1).name).range(currange)
   next
errorhandler:
      curcell.offset(0, -1).value = "no"
    resume next
end sub

表格形式為:a列 和b列.  匹配條件是:按行查詢,若第一行的a列單元格內(nèi)容等于另一行b列單元格內(nèi)容,就檢查第一行b列單元格內(nèi)容是否等于另一行a列單元格內(nèi)容,若相等就在這兩行前做標(biāo)記.否則標(biāo)記為no

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 方山县| 宽甸| 诸暨市| 桑日县| 六盘水市| 星子县| 清水河县| 英超| 尖扎县| 会东县| 隆林| 太仓市| 丹寨县| 邻水| 石门县| 嵩明县| 廉江市| 封开县| 眉山市| 浦县| 晋江市| 同仁县| 吴江市| 桓台县| 张北县| 丹凤县| 陈巴尔虎旗| 神农架林区| 土默特左旗| 小金县| 濮阳市| 大姚县| 尖扎县| 尼玛县| 清水县| 崇文区| 贵定县| 铁岭县| 白玉县| 同仁县| 阿拉善盟|