{"id":806,"date":"2024-06-20T08:45:42","date_gmt":"2024-06-20T00:45:42","guid":{"rendered":"http:\/\/www.wyrcad.com\/?p=806"},"modified":"2024-06-25T08:47:53","modified_gmt":"2024-06-25T00:47:53","slug":"%e6%8f%90%e5%8f%96%e5%ad%97%e7%ac%a6%e4%b8%b2","status":"publish","type":"post","link":"https:\/\/www.wyrcad.com\/?p=806","title":{"rendered":"Excel \u51fd\u6570\u7cfb\u5217\u4e4b\u4e00"},"content":{"rendered":"\n<p>Public Function MinRow(ByVal vSheet As Variant) As Integer &#8216;\u6709\u5185\u5bb9\u7684\u6700\u5c0f\u884c\u53f7<br>MinRow = -1<br>On Error Resume Next<br>If vSheet Is Nothing Then Exit Function<br>vSheet.Activate<br>MinRow = vSheet.UsedRange.Rows(vSheet.UsedRange.Rows.Count).Row &#8211; vSheet.UsedRange.Rows.Count + 1<br>On Error GoTo 0<br>End Function<\/p>\n\n\n\n<p>Public Function MaxRow(ByVal vSheet As Variant) As Integer &#8216;\u6709\u5185\u5bb9\u7684\u6700\u5927\u884c\u53f7<br>MaxRow = -1<br>On Error Resume Next<br>If vSheet Is Nothing Then Exit Function<br>vSheet.Activate<br>MaxRow = vSheet.UsedRange.Rows(vSheet.UsedRange.Rows.Count).Row<br>On Error GoTo 0<br>End Function<\/p>\n\n\n\n<p>Public Function MinColumn(ByVal vSheet As Variant) As Integer &#8216;\u6709\u5185\u5bb9\u7684\u6700\u5c0f\u5217\u53f7<br>MinColumn = -1<br>On Error Resume Next<br>If vSheet Is Nothing Then Exit Function<br>vSheet.Activate<br>MinColumn = vSheet.UsedRange.Columns(vSheet.UsedRange.Columns.Count).Column &#8211; vSheet.UsedRange.Columns.Count + 1<br>&#8216;vSheet.Cells.Find(&#8220;*&#8221;, , , , 2, 1).Column \u540c<br>On Error GoTo 0<br>End Function<\/p>\n\n\n\n<p>Public Function MaxColumn(ByVal vSheet As Variant) As Integer &#8216;\u6709\u5185\u5bb9\u7684\u6700\u5927\u5217\u53f7<br>MaxColumn = -1<br>On Error Resume Next<br>If vSheet Is Nothing Then Exit Function<br>vSheet.Activate<br>MaxColumn = vSheet.UsedRange.Columns(vSheet.UsedRange.Columns.Count).Column<br>&#8216;vSheet.Cells.Find(&#8220;*&#8221;, , , , 2, 2).Column \u540c<br>If Err.Number &lt;&gt; 0 Then Call SaveOccurredErr(1)<br>If Not ExposeError Then On Error GoTo 0<br>End Function<\/p>\n\n\n\n<p>Public Function SheetExist(ByVal vBook As Variant, ByVal sSheet As String) As Boolean &#8216;\u5f53\u524d WorkBook \u4e4b Sheet \u5b58\u5728<br>On Error Resume Next<br>Dim I As Integer, J As Integer<br>SheetExist = False<br>If vBook Is Nothing Then Exit Function<br>&#8216;If vSheet Is Nothing Then Exit Function<br>For I = 1 To vBook.Sheets.Count<br>If vBook.Sheets(I).Name = sSheet Then SheetExist = True<br>Next I<br>If Err.Number &lt;&gt; 0 Then SheetExist = False<br>On Error GoTo 0<br>End Function<\/p>\n\n\n\n<p>Public Function GetColumnNumber(ByVal vSheet As Variant, ByVal sData As String, ByVal iRow As Integer) As Integer &#8216;\u786e\u5b9a\u6570\u636e\u5728\u67d0\u884c\u7684\u54ea\u4e00\u5217,\u5982\u679c\u4e0d\u5b58\u5728\u5219\u6307\u5411\u65b0\u5217<br>Dim I As Integer, J As Integer<br>GetColumnNumber = 0<br>If vSheet Is Nothing Then Exit Function<br>vSheet.Activate<br>For J = MinColumn(vSheet) To MaxColumn(vSheet)<br>If sData = vSheet.Cells(iRow, J) Then GetColumnNumber = J<br>Next J<br>If GetColumnNumber = 0 Then GetColumnNumber = MaxColumn(vSheet) + 1<br>End Function<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Public Function MinRow(ByVal vSheet As Variant) As Inte &hellip; <a href=\"https:\/\/www.wyrcad.com\/?p=806\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cExcel \u51fd\u6570\u7cfb\u5217\u4e4b\u4e00\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[24,17],"class_list":["post-806","post","type-post","status-publish","format-standard","hentry","category-bianchengyuandi","tag-vb","tag-biancheng"],"_links":{"self":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/806","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=806"}],"version-history":[{"count":5,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/806\/revisions"}],"predecessor-version":[{"id":889,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/806\/revisions\/889"}],"wp:attachment":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=806"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=806"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=806"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}