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

機械社區

 找回密碼
 注冊會員

QQ登錄

只需一步,快速開始

搜索
查看: 1506|回復: 3
打印 上一主題 下一主題

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

[復制鏈接]
跳轉到指定樓層
1#
發表于 2022-6-6 18:03:11 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
Option Compare Text
7 C* L2 D' K) x: e. |$ g1 X$ P& K. v" L
Public Function GSXS(Ref)) O1 C0 w$ {9 R: k' c5 m# [

8 ]$ @2 u# i9 y8 |( |! l' N8 m    GSXS = Ref.Formula, d$ M. I4 {% `0 Z5 i

* d0 P& b% w' B* iEnd Function
* n, ^) v% A( h
3 [) O* S- F. V0 \! JPublic Function ZZL(RowHead, ColHead, Dummy)
* I$ K+ \9 j2 W3 D" Z+ T$ h
5 F: e" l6 o0 A0 p* WDim Values(20) As Variant- v5 A" y7 B. F0 W9 [. n1 C& c
Dim PrevData(20) As Variant9 T2 z, L/ h# \
Dim LE(20) As Integer
) F  ~) D% x6 @3 x6 W5 X3 v& y8 W' v9 s& B& t/ R
On Error GoTo err_handler1( l2 K1 N7 M' f8 ~  t# m& S
' Do the vertical selection from rows9 n. m1 B' c# _6 X: K, L
If RowHead.Rows.Count = 1 Then# q! C. k$ g- ?$ L  ?" c8 m* H/ J
    rindex = RowHead.Row    ' first argument is any cell on the row of possible values, D6 W, R  E; n( }
Else7 |8 I2 R8 ~$ Z) n5 `# P; V% K
    ' Store the values to be compared with each column5 |: s5 @3 c& x" x3 y% [. L! r, I
    For ii = 1 To RowHead.Columns.Count$ s$ {0 Y$ J  h3 o* u$ q* {/ s6 w1 x
        rngname = RowHead.Cells(1, ii)
/ n# F0 I3 A( X( ?+ c2 d1 v6 z% i, }2 P        LE(ii) = InStr(rngname, "<=")
& a# m5 x4 v# X' p) T1 X3 F        If LE(ii) > 0 Then
- b7 _- }& i' E, ~- V: G3 d            rngname = Mid(rngname, 1, LE(ii) - 1)
% a# c/ [9 y$ |        End If
" F7 ~* E3 t9 z, H& X        Values(ii) = Range(rngname)1 b& @/ k8 z+ Y! C" c
        'debug.Print "Variable:" & rngname & " is:" & Values(ii)
" Q' S. y% W; s" a, I/ S- x        PrevData(ii) = ""   ' initialise
6 s- E7 \' ~) G: n    Next ii
) U1 C& S" n/ ~8 l. `( }+ r, g/ B; S5 E0 [0 q9 h6 H% ?6 w
    rindex = 2. ]/ d# t" v7 O6 K6 D
    'debug.Print RowHead.Columns.Count
8 X4 ^8 J! `. q- |    Match = False4 T1 M+ ]" a& l0 `8 g. |& M
    For r = rindex To RowHead.Rows.Count
) J6 V" Y- |6 o        For c = 1 To RowHead.Columns.Count   ' for each dimension: K( V" L) K3 \$ ?# J1 _
            data = RowHead.Cells(r, c)
2 j; r3 [$ I, P6 i& `            If data = "" Then4 |6 N; }- \6 w% Y5 x* p
                'debug.Print "Empty cell found: using " & PrevData(c)2 R& f3 D- G# X7 p4 u3 K
                ' use the last valid cell in this column
, g5 V: D. _& Y9 I, ]* n                ' (this is to handle merged cells)& H: F9 g) @* v+ D
                data = PrevData(c)1 h1 x# E( p3 B9 I  n: ^  n
            End If. ?& _9 g, Y8 R2 E. t
            'debug.Print "data:" & data
6 M2 n' {4 \# t! b: [            PrevData(c) = data ' save for use by empty cells
6 n( Y4 E3 @4 q% D& B            If data = Values(c) Or (data > Values(c) And LE(c) > 0) Or data = "*" Then
" Q7 i) v: l5 k; y5 s! o! L8 Q) K/ o                If c = RowHead.Columns.Count Then   ' All columns match - It's a go
$ I- k% Q+ Q( G+ ]6 g" Z                    Match = True# @3 {8 k& v/ X' U
                End If/ B9 E! ?& M, B: B# M
            Else    ' This column doesn't match - go to the next row6 v& u  {+ g( b+ K( h8 j5 Z% X% f' U
                Match = False* ]  R: @8 c, f6 ?; }  H; d* O
                Exit For6 q4 i  @* J+ r7 _# k
            End If
' d( \1 c% _& y- _0 D        Next c% B! X9 Y; \( D) V, Q& V  m8 c
        If Match = True Then    ' Don't search any more rows
- d. B  V. y: t6 M2 O4 {, a            rindex = r& D- Z& j8 G9 i6 A
            Exit For) l/ c; k) j( Y" a
        End If2 P% B( L/ ~% H, k, ^
    Next r/ o. F6 ?  q& X+ _2 A; r& r: \
0 L2 ]6 L$ }* r; C6 w7 x; D3 v
    If Match = False Then   ' Didn't find a matching set of values
* z8 j" c+ B4 i3 \- s        ZZL = "No match for rows"5 j4 p5 Z8 O+ V7 G: {8 F! `6 v& l
        Exit Function% R+ I) d$ @* c# p
    End If1 v3 y8 \* E# ?$ Y# U6 o6 h) m

- C6 z$ c: v5 t2 c6 S2 V& B7 `    rindex = rindex + RowHead.Row - 1   ' make absolute index& v% x* f2 t: |8 z# I
End If( u8 y( D* A' j. k5 x3 ~
9 F$ D8 g: v8 y6 _: W6 r
' Do the horizontal selection from columns
* ^& ^+ U4 d; B  e9 |. i& E0 C9 e+ D* MIf ColHead.Columns.Count = 1 Then
4 s% y! A9 d  N' ^    cindex = ColHead.Column
. p/ G* t+ F5 P( b% M/ r8 x% z9 kElse
( e: V4 g" I) Q( ]! o    ' Store the values to be compared with each row of the header) c- _) d; D: U1 k6 N4 U! R2 `
    For ii = 1 To ColHead.Rows.Count3 ~. [. a: d. Q1 T
        rngname = ColHead.Cells(ii, 1)
$ I. e0 u1 \8 k3 Z* Y4 G        LE(ii) = InStr(rngname, "<=")
% e6 U3 N! E/ W# H. G' E, y        If LE(ii) > 0 Then
1 Q. B6 w7 N4 Q+ }2 G6 _% J            rngname = Mid(rngname, 1, LE(ii) - 1)5 D' M% u( W( z7 i
        End If0 ], t  Q/ C9 Q$ j$ v/ |
        Values(ii) = Range(rngname)
# d" F9 G2 G8 M) d        'debug.Print "Variable:" & rngname & " is:" & Values(ii)9 _/ D% u( H  P% x
        PrevData(ii) = ""   ' initialise5 H/ }0 a* P/ Z2 ^' P0 Y' `
    Next ii
" d# Z" Q* ]1 H( O: i  U
  o  d- `* F4 u' e    cindex = 2
3 f; V( b9 V4 {, S4 d8 H+ R5 V* ]- c    'debug.Print ColHead.Columns.Count) V& t7 q& t: ~4 k
    Match = False  W1 h8 |, R: G
    For c = cindex To ColHead.Columns.Count
8 L+ L& \/ O4 v% n; l' J        For r = 1 To ColHead.Rows.Count   ' for each dimension' G' V8 i- a9 D0 S6 I5 x
            data = ColHead.Cells(r, c)2 L, {- @; p( B/ a6 }- m7 y$ {1 f$ T$ m
            If data = "" Then
8 A' e5 q! L/ l# p- Q6 d4 w% Z                'debug.Print "Empty cell found: using " & PrevData(r)
4 M4 S" P4 U  N                ' use the last valid cell on this row% k& a8 J- k$ m% [: `
                ' (this is to handle merged cells)& R- y7 O  j/ s8 y3 |4 z
                data = PrevData(r)
2 L& Z3 [4 Y. }+ U3 c! Q% k. ?/ [/ U            End If* n) t8 t% J4 O0 t  y
            'debug.Print "data:" & data- y) a, Q8 F7 g' N/ h4 c- W
            PrevData(r) = data ' save for use by empty cells
9 P) p. C' q' f  j            If data = Values(r) Or (data > Values(r) And LE(r) > 0) Or data = "*" Then9 {- o* Z+ y; N6 T# j! G
                If r = ColHead.Rows.Count Then   ' All rows match - It's a go
3 r* y, Z( _+ j                    Match = True
: |4 ]/ h' {: a, b; i9 Z                End If
% Q9 X! S& D6 K4 r! t            Else    ' This row doesn't match - go to the next column
# Q+ r/ [" t6 h% p, S6 u: W: h                Match = False  \/ e" H5 N' o# t: ?, d& s. R
                Exit For$ u& [7 N6 W  j: Q. Z5 b1 D- r! ?
            End If
8 p# Q0 L! S/ g# F0 t        Next r$ k6 X- X  I/ y
        If Match = True Then    ' Don't search any more columns" [0 m- m6 M8 Q! a/ s& i
            cindex = c" z# k8 A3 ^" x# Y6 h
            Exit For
4 U: M0 @- h/ U1 X( Z% R# |        End If
5 ?4 e& J: M6 P% i' Q    Next c
; J$ |6 \  n0 D" o+ y
5 T1 U2 g) V; _, G' G& _; A+ h    If Match = False Then   ' Didn't find a matching set of values; V+ P- z) z4 O% V
        ZZL = "No match for columns"* ?) [1 T% L$ ]4 Z8 f
        Exit Function
1 ?. j; `. l% N0 W4 p    End If1 d1 |7 ]8 h5 ~, {
0 P2 n- k* X4 u7 m
    cindex = cindex + ColHead.Column - 1
$ D+ B. D7 O7 _5 j2 f$ K3 ]; L* tEnd If( O& K8 X. h& ]

+ r/ [6 b1 P/ A) e' Return the cell value from Table
9 _/ H# Y" k/ u. _4 ^3 Q& H: s1 O'debug.Print "Answer is in (R,C):  " & rindex, cindex
  J& A& I, c% A5 C8 OZZL = ActiveSheet.Cells(rindex, cindex). n  \9 [( b* \& p9 }# |
'debug.Print "Answer is : " & ZZL2 `- s  L  p+ E; ~: A6 C  ^7 t5 K2 O) t# w
Exit Function
' K1 r6 x8 ]" H( g7 {0 A" ?( G3 \+ g) |4 R2 L- f, r! @/ I
err_handler1:
' s0 m# m2 s% _: z. m  l) H/ CZZL = "Error on range '" & rngname & "'"
" S# q) ?, {' C. B5 o2 K7 ]' N5 x& v* G
End Function1 M' l& j3 f- v
; }; H# _, |& Q- }3 F
回復

使用道具 舉報

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

使用道具 舉報

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

使用道具 舉報

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

使用道具 舉報

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

本版積分規則

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

GMT+8, 2025-5-11 04:02 , Processed in 0.052583 second(s), 13 queries , Gzip On.

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 亚洲色欲色欲欲www在线 | v一区无码内射国产| 精品亚洲麻豆1区2区3区| a欧美亚洲日韩在线观看| 成熟丰满熟妇高潮xxxxx| 84pao国产成视频永久免费| 四虎国产精品免费久久| 国产精品免费视频色拍拍| 婷婷亚洲久悠悠色悠在线播放| 无码小电影在线观看网站免费| 青青草av一区二区三区| 日韩精品一区二区三区影院| 欧美成人精品午夜免费影视| 欧美乱人伦人妻中文字幕| 成人亚洲性情网站www在线观看| 蜜臀国产在线视频| 欧美激情一区二区| 免费观看性欧美大片无片| 亚洲一区二区三区国产精华液 | 蜜桃av无码免费看永久| 一区二区日韩在线观看| 18禁成年免费无码国产| 精品一区二区黄| 婷婷伊人久久大香线蕉av| 亚洲精品日本无v一区| 亚洲精品国产精品国产自2022| 人人妻人人人澡人人爽欧美一区| 亚洲—本道中文字幕东京热| 久久视频在线观看精品| 亚洲日韩中文字幕久热| 99久久九九免费观看| 午夜电影 日韩一区二区三区| 亚洲精品久久久久国色天香| 亚洲精品国产自在久久| 欧美孕妇变态重口另类| 性色一区二区三区| 97久久久久人妻精品区一| av蜜臀一区二区三区多人| 亚洲人成伊人成综合网久久久| 2019精品手机国产品在线| 久久久久久综合网天天|