国产日韩欧美久久久精品图片|国产综合有码无码中文字幕|国产一区二区综合视频|国产亚洲精品电影网站在线观看|国产精品一区在线

機(jī)械社區(qū)

 找回密碼
 注冊會員

QQ登錄

只需一步,快速開始

搜索
查看: 1508|回復(fù): 3
打印 上一主題 下一主題

excel 中BVA 麻煩大佬幫忙解釋一下

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
1#
發(fā)表于 2022-6-6 18:03:11 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
Option Compare Text
8 C/ B& d1 M2 D3 F3 E( q+ C8 B$ H7 p7 |% _
Public Function GSXS(Ref)" \7 E" E8 C3 T' o7 x6 ]
" A; y7 d# Y" p: I; F
    GSXS = Ref.Formula
& W, e; N- n  [! z: y7 u/ u7 X7 K, i, E  _8 \
End Function
. o5 `: V1 `' Q4 o
, C2 s/ T* x' w6 F! H* u- P! J# DPublic Function ZZL(RowHead, ColHead, Dummy)! X+ F3 M! L0 v2 C
/ t, _: V7 V7 D3 v
Dim Values(20) As Variant
' _- {7 Q% b" `7 gDim PrevData(20) As Variant
/ V1 K2 M1 q. d' q2 KDim LE(20) As Integer$ g& h) {# F. c8 B
$ K% R3 C5 ^: R7 b4 T( V
On Error GoTo err_handler11 {7 c& \9 B5 x# s% D
' Do the vertical selection from rows0 [. t# G4 w) F# ~" I
If RowHead.Rows.Count = 1 Then
" [; T' Z( E7 I9 \7 _    rindex = RowHead.Row    ' first argument is any cell on the row of possible values1 f- X1 L8 F( \6 X
Else' X3 u& r7 t; I+ A6 E- a
    ' Store the values to be compared with each column; N1 u9 p/ |% k- v" N, ~
    For ii = 1 To RowHead.Columns.Count* O: m& W; X, U& f; ~8 r
        rngname = RowHead.Cells(1, ii)
, h  c2 j! C- T* ~$ P: a        LE(ii) = InStr(rngname, "<=")( X, |+ ?% |+ b; g& a! o
        If LE(ii) > 0 Then: l' u7 K7 I6 Q/ m5 x
            rngname = Mid(rngname, 1, LE(ii) - 1)
; L+ f9 F* A* b8 p+ S) d        End If8 g, D& i/ Z3 |% ^/ n% R
        Values(ii) = Range(rngname)- S0 j! b# m. H0 U
        'debug.Print "Variable:" & rngname & " is:" & Values(ii)9 f/ ^5 G6 z6 |2 o5 Q6 h
        PrevData(ii) = ""   ' initialise: i: N& z4 R; T/ f
    Next ii
$ Q$ S: v' |0 M. X+ d6 ]% E3 n. \3 G
    rindex = 22 e" j# O% }3 c5 P( g6 \+ R
    'debug.Print RowHead.Columns.Count
  n# C: Z$ u& c9 x: w# i0 |' Z( v    Match = False
1 l0 E6 S, Y9 e  W5 P9 w6 e0 Z  l    For r = rindex To RowHead.Rows.Count
! p8 s5 o2 Y  D6 F6 [        For c = 1 To RowHead.Columns.Count   ' for each dimension
' w) P' S6 T1 P            data = RowHead.Cells(r, c)
4 c: u0 J: U# j" @' y            If data = "" Then
$ R4 n2 E: ^: k: k; S7 I                'debug.Print "Empty cell found: using " & PrevData(c)8 J1 n9 p( z) V" B* n
                ' use the last valid cell in this column
# O! S- r8 K: @9 G' h                ' (this is to handle merged cells)
6 x4 V" c( Q! p. ?0 w! p" V                data = PrevData(c)
& C5 r& |( S% Q( C* I0 p! X3 i            End If! D9 y9 ~6 I! \, s/ b$ [4 L
            'debug.Print "data:" & data
# g/ M" `3 M! ^6 n            PrevData(c) = data ' save for use by empty cells) ]: z. v/ p: |) R$ ^0 U! Y
            If data = Values(c) Or (data > Values(c) And LE(c) > 0) Or data = "*" Then
: ~$ d/ Y4 P1 A" J                If c = RowHead.Columns.Count Then   ' All columns match - It's a go
+ ~4 i. s% ]7 T# x- e                    Match = True% O$ c3 q. g; |/ D. h- o. c
                End If( L8 U: i  m8 \# C# e! G
            Else    ' This column doesn't match - go to the next row
) p7 }: Q: q/ n* q9 X                Match = False# r( ?+ z" D% e
                Exit For0 L' I- b# h1 {. ^1 }2 o0 v# s" m
            End If; `5 \/ s* i  z/ Q
        Next c
- {8 W9 o! ]! {1 V        If Match = True Then    ' Don't search any more rows* d  t2 a4 q% l, K( t, S
            rindex = r
$ v9 k- {1 E6 \0 x, X  e1 y* @/ P            Exit For
& ?& y: h, }! M" v        End If
  k0 N# V& F$ |6 z9 M    Next r* J3 s6 }% ?$ M2 O7 H( d2 `8 e

3 X5 k! i8 w9 S2 Y2 \" a    If Match = False Then   ' Didn't find a matching set of values$ u% |/ |% r+ V1 Y7 [
        ZZL = "No match for rows"( z: E# T, i  L
        Exit Function
  X7 w+ G* T) R" p/ X# ~  X. H$ m# L    End If
$ ^# X( v6 W" Z$ P: ]% o" _% \5 b+ L. b. g0 ^  a
    rindex = rindex + RowHead.Row - 1   ' make absolute index
! d4 U! d5 {- w7 `End If! v$ \* D3 W( x! k

" ~  z; k2 ]- \4 b' Do the horizontal selection from columns6 V+ C: P' Q  b4 d
If ColHead.Columns.Count = 1 Then
/ u. y& x& U# S; Y" {5 P$ ]    cindex = ColHead.Column' q+ {8 j- b8 G. q6 {$ C
Else
/ k( M; `% x, x4 M+ E3 d    ' Store the values to be compared with each row of the header
" B0 z3 A0 I" V4 j8 \    For ii = 1 To ColHead.Rows.Count
) l: L- V& Y" m3 @$ y5 @        rngname = ColHead.Cells(ii, 1)
! Y& M9 s$ B8 W6 h# j) X; I1 I        LE(ii) = InStr(rngname, "<=")2 P$ E3 s0 S  s  W# d
        If LE(ii) > 0 Then/ N& U/ K: g7 N- K4 y# L* p
            rngname = Mid(rngname, 1, LE(ii) - 1)# h/ p1 u/ b  B
        End If9 b7 h% L; L( E' N, j1 V! |! A( R
        Values(ii) = Range(rngname)$ |# _# f4 c$ }. N6 Y) ?# v
        'debug.Print "Variable:" & rngname & " is:" & Values(ii)
/ \6 }# q+ Z5 m+ X' j/ j0 ]        PrevData(ii) = ""   ' initialise9 _% e- l3 E3 {$ E. |  r' t
    Next ii( x- g; ]6 \  \' \

; Y1 J# B7 [" i$ [( L    cindex = 2& @! c. U( W6 I* x* u8 K
    'debug.Print ColHead.Columns.Count
/ X3 t  b9 a9 j$ d1 i    Match = False
) x9 T' T  C8 t+ O5 Q6 L0 e: O    For c = cindex To ColHead.Columns.Count
) L5 E$ H% T: R  `! q+ L: x        For r = 1 To ColHead.Rows.Count   ' for each dimension
: y5 j1 N' j6 ]9 a0 k# B            data = ColHead.Cells(r, c)
7 z; e; }# X" n" `7 `9 t            If data = "" Then% k( @/ m7 m# c" R5 x0 n# W
                'debug.Print "Empty cell found: using " & PrevData(r)
& K" v- T" ~: }2 J0 U" K                ' use the last valid cell on this row! L& L8 B  P8 K" V+ o
                ' (this is to handle merged cells)
1 }* r2 B6 K; ?" s! \1 R$ s                data = PrevData(r)) J0 X% }+ ~! I. q2 E2 l" A
            End If
+ s3 }+ D3 z- |7 _7 k) `            'debug.Print "data:" & data
; M$ L& G- G! g8 F            PrevData(r) = data ' save for use by empty cells8 C* H9 S* e/ L$ Z% o# D
            If data = Values(r) Or (data > Values(r) And LE(r) > 0) Or data = "*" Then
$ H( |1 N- h1 y5 ^' l                If r = ColHead.Rows.Count Then   ' All rows match - It's a go
9 E5 j1 _! g( m9 J2 e5 r/ O7 H! T                    Match = True. e& n* _! P3 ?- K9 e) \
                End If: V* x! s' T' M) m
            Else    ' This row doesn't match - go to the next column- R/ b% m. A( Y- M
                Match = False
' x( b3 q2 t, `$ q& W# |7 e( t                Exit For
' R$ I# k8 z9 _            End If
) o' ~5 k+ A7 ^, k        Next r
3 `& T! W' n3 n2 C) J        If Match = True Then    ' Don't search any more columns' s  U7 _. M" B3 c4 ^/ Q+ t
            cindex = c3 k) [7 O( C  X
            Exit For2 V9 |8 q% u, w7 d( [( O3 e' o
        End If# R" c( I7 Y! q) v( z" I
    Next c; M+ v1 U( ?. g: ]. T
4 m1 H( K' L# G/ T9 _) N
    If Match = False Then   ' Didn't find a matching set of values8 [3 y' \4 l, N3 m; d
        ZZL = "No match for columns"6 Q6 L! `6 k- [% {
        Exit Function! m0 |' ]! `' r. }8 C$ Z
    End If  W1 ^" M% N! I2 w+ l' i* G& ~- p
% i/ f3 _* Z' }* u7 G
    cindex = cindex + ColHead.Column - 1
  V3 V$ [+ I2 TEnd If! ^% y4 |) e# b" i

3 a* v' C" Q3 z3 {7 z- c' Return the cell value from Table
+ I' K% ^4 {( K" _8 F5 U: ?. N'debug.Print "Answer is in (R,C):  " & rindex, cindex
- A/ ]- C, R5 a* v7 P6 VZZL = ActiveSheet.Cells(rindex, cindex)0 W0 ], R- ]* E; u
'debug.Print "Answer is : " & ZZL
6 g0 ~; _+ W+ W7 x3 x5 CExit Function
& [  B7 G. R! B+ |
7 H! O; f, u) {9 Xerr_handler1:- C8 U6 P" y; i
ZZL = "Error on range '" & rngname & "'"  z' Z4 g. R4 X# F- P
" o5 q, E  v2 [. i; Y/ y- u* v8 G# f
End Function3 M0 `& b7 h2 _, K' M
- b+ u) O/ L6 }
回復(fù)

使用道具 舉報

2#
 樓主| 發(fā)表于 2022-6-6 18:04:26 | 只看該作者
本人是小白,想請教大佬,如何能看懂以上信息
回復(fù) 支持 反對

使用道具 舉報

3#
發(fā)表于 2022-6-6 19:17:09 | 只看該作者
微軟官方的bbs里是有專業(yè)的VBA教程和API端口說明能檢索的(全英文)
回復(fù) 支持 反對

使用道具 舉報

4#
發(fā)表于 2022-6-7 08:52:01 | 只看該作者
上excel論壇問問看
回復(fù) 支持 反對

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 注冊會員

本版積分規(guī)則

小黑屋|手機(jī)版|Archiver|機(jī)械社區(qū) ( 京ICP備10217105號-1,京ICP證050210號,浙公網(wǎng)安備33038202004372號 )

GMT+8, 2025-5-12 04:45 , Processed in 0.057282 second(s), 13 queries , Gzip On.

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 亚洲欧美日韩精品专区| 久久精品无码一区二区软件| 精品国产无套在线观看| 伊人色合天天久久综合网| 好爽…又高潮了毛片免费看| 黑人粗长大战亚洲女| 亚洲尺码电影av久久| 水牛影视一区二区三区久| 亚洲成人一区二区| 精品深夜av无码一区二区老年| 中字幕人妻一区二区三区| 在线观看一区二区三区国产免费 | 无码视频一区二区三区在线观看 | 国产精华av午夜在线| 中文字幕av久久激情亚洲精品 | 波多野结衣一区二区免费视频| 少妇人妻系列无码专区系列| 国产一区二区网| 自拍偷自拍亚洲精品第1页| 肉体裸交丰满丰满少妇在线观看| 久久精品人人做人人爽电影蜜月| 中本亚洲欧美国产日韩| 色天天躁夜夜躁天干天干| 2019久久久高清456| 97久久精品人妻人人搡人人玩| 中文字幕av一区二区三区| 亚洲国产欧美一区二区三区在线观看| 自拍日韩亚洲一区在线| 亚洲女人自熨在线视频| 欧美激情精品久久| 无码精品人妻一区二区三区人妻斩| 中文字幕在线观看一区二区三区四区 | 377人体粉嫩噜噜噜| 亚洲熟妇无码久久精品| 中文文字幕文字幕亚洲色| 国产激情视频在线观看的| 欧美成人精品第一区二区三区| 久久亚洲中文字幕精品有坂深雪 | 高潮毛片无遮挡高清视频播放| 精品无码久久久久久久久久| 999精品视频在这里|