{"id":676,"date":"2023-12-01T18:01:01","date_gmt":"2023-12-01T10:01:01","guid":{"rendered":""},"modified":"2023-12-01T18:01:01","modified_gmt":"2023-12-01T10:01:01","slug":"Excel-VBA\uff1a14\u3001\u6570\u7ec4","status":"publish","type":"post","link":"https:\/\/mushiming.com\/676.html","title":{"rendered":"Excel-VBA\uff1a14\u3001\u6570\u7ec4"},"content":{"rendered":"
\n

excel\u6570\u636e\u5b58\u653e\u7684\u4f4d\u7f6e\uff1a\u5355\u5143\u683c\u548c\u5185\u5b58<\/p>\n

\u5982\u679c\u6570\u636e\u5b58\u653e\u518d\u5355\u5143\u683c\u4e2d\uff0c\u7cfb\u7edf\u8ba1\u7b97\u9700\u8981\u4e24\u6b65\uff1a1\uff0c\u63d0\u53d6\u6570\u636e\uff0c\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d\uff1b2\u3001\u8fd0\u7b97\u5185\u5b58\u4e2d\u7684\u6570\u636e\u3002\u800c\u6570\u636e\u5982\u76f4\u63a5\u5728\u5185\u5b58\u4e2d\uff0c\u5219\u53ef\u4ee5\u76f4\u63a5\u8fdb\u884c\u8fd0\u7b97\uff0c\u4ece\u800c\u8282\u7701\u5927\u91cf\u7684\u65f6\u95f4\uff0c\u6ce8\u610f\uff1a\u662f\u5927\u91cf\u7684\u65f6\u95f4\u3002<\/p>\n

\u6570\u7ec4\uff1a\u53ef\u4ee5\u5c06\u4e00\u7ec4\u6570\u636e\u5b58\u50a8\u5728\u5185\u5b58\u4e2d\uff0c\u53ef\u4ee5\u5b58\u653e\u6587\u672c\u3001\u6570\u503c\u3001\u5bf9\u8c61\u7b49\u3002<\/p>\n

VBA\u6570\u7ec4\u662f\u4ee5\u53d8\u91cf\u5f62\u5f0f\u5b58\u653e\u7684\u4e00\u4e2a\u7a7a\u95f4\u3002<\/p>\n

\u6570\u7ec4\u5206\u7c7b\uff1a\u5e38\u91cf\u6570\u7ec4\u3001\u9759\u6001\u6570\u7ec4\u548c\u52a8\u6001\u6570\u7ec4<\/p>\n

\u5e38\u91cf\u6570\u7ec4\uff1a\u6570\u7ec4\u7a7a\u95f4\u5927\u5c0f\u548c\u5143\u7d20\u5747\u5df2\u786e\u5b9a<\/p>\n

\u9759\u6001\u6570\u7ec4\uff1a\u6570\u7ec4\u7a7a\u95f4\u5927\u5c0f\u5df2\u786e\u5b9a\uff0c\u4f46\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u5c1a\u672a\u786e\u5b9a<\/p>\n

\u52a8\u6001\u6570\u7ec4\uff1a\u6570\u7ec4\u7684\u7a7a\u95f4\u548c\u5143\u7d20\u90fd\u672a\u786e\u5b9a<\/p>\n

1\u3001\u6570\u7ec4\u5199\u5165\u6570\u636e<\/strong><\/h1>\n

1.1\u3001\u4e00\u7ef4\u6570\u7ec4\u5199\u5165\u6570\u636e<\/p>\n

Sub test()\nDim arr(10), x!\nFor x = 0 To 10\n arr(x) = x\nNext x\nEnd Sub\n<\/pre>\n

\u6ce8\u610f<\/strong><\/p>\n

arr(10) \u7684\u53d6\u503c\u8303\u56f4\u662f[0,10]\uff0c\u4e00\u517111\u4e2a\u6570\u5b57\uff0c\u5982\u679c\u8981\u6307\u5b9a\u4ece1\u523010\uff0c\u5219\u6307\u5b9a\u5177\u4f53\u7684\u53d6\u503c\u8303\u56f4\uff1aarr(1 To 10)<\/p>\n

\u4e00\u7ef4\u6570\u7ec4\u5373\u5355\u884c\u5355\u5217\u7ed3\u6784<\/p>\n

1.2\u3001\u4e8c\u7ef4\u6570\u7ec4\u5199\u5165\u6570\u636e<\/strong><\/p>\n

Sub test()\nDim arr(1 To 5, 1 To 3), x!, y!, i!\nFor x = 1 To 5\n For y = 1 To 3\n arr(x, y) = i\n i = i + 1\n Next y\nNext x\nEnd Sub\n<\/pre>\n

\u8bf4\u660e<\/strong><\/p>\n

\u4e8c\u7ef4\u6570\u7ec4\u5373\u591a\u884c\u591a\u5217\u7ec4\u6210\u7684\u533a\u57df<\/p>\n

\u4e09\u7ef4\u6570\u7ec4\u662f\u5de5\u4f5c\u8868\u548c\u533a\u57df\u5171\u540c\u7ec4\u6210\u7684\u7ed3\u6784\uff0c\u5982arr(\u5de5\u4f5c\u8868\uff0c\u884c\uff0c\u5217\uff09<\/p>\n

2\u3001\u52a8\u6001\u6570\u7ec4<\/strong><\/h1>\n

\u52a8\u6001\u6570\u7ec4\u4f7f\u7528\u9700\u8981\u4e24\u6b65<\/p>\n

\u7b2c\u4e00\u6b65\uff1a\u58f0\u660e\u6570\u7ec4\u53d8\u91cf,\u4e0d\u6307\u5b9a\u7a7a\u95f4\u5927\u5c0f<\/p>\n

[\u4ee3\u7801\u5757]<\/p>\n

\u7b2c\u4e8c\u6b65\uff1aReDim \u6570\u7ec4\u53d8\u91cf\u540d\uff08\u6570\u7ec4\u7a7a\u95f4\u5927\u5c0f\uff09<\/p>\n

3\u3001\u6570\u7ec4\u7684\u6279\u91cf\u5199\u5165<\/strong><\/h1>\n

3.1\u3001\u4f7f\u7528Array\u51fd\u6570\u5199\u5165<\/strong><\/p>\n

Sub t()\nDim arr ' \u4e0d\u53ef\u4ee5\u6307\u5b9a\u7c7b\u578b\narr = Array(1,2,3,\"a\")\nEnd Sub\n<\/pre>\n

3.2\u3001\u5355\u5143\u683c\u533a\u57df\u5199\u5165<\/p>\n

\u7ed3\u679c\uff1aarr\u662f\u4e00\u4e2a\u7531B3:F5\u503c\u7ec4\u6210\u7684\u4e8c\u7ef4\u6570\u7ec4\uff0c\u5982\u679c\u7531\u7a7a\u5355\u5143\u683c\uff0c\u503c\u4e3a\u7a7a<\/p>\n

Sub test()\nDim arr\narr = [b3:f5]\nEnd Sub\n<\/pre>\n

\u7ed3\u679c\uff1aarr\u662f\u4e00\u4e2a\u7531B3:F5\u503c\u7ec4\u6210\u7684\u4e8c\u7ef4\u6570\u7ec4\uff0c\u5982\u679c\u7531\u7a7a\u5355\u5143\u683c\uff0c\u503c\u4e3a\u7a7a<\/p>\n

\u6ce8\u610f<\/strong><\/p>\n

\u5982\u679cDim arr\u58f0\u660e\u4e86\u4e00\u4e2a\u6570\u7ec4\uff0c\u5219\u6b64\u6570\u7ec4\u4e3a\u4e8c\u7ef4\u6570\u7ec4\uff0c\u5373\u4f7farr=[a1:a10]\uff0c\u8be5\u6570\u7ec4\u4e5f\u662f\u4e00\u4e2a10\u884c1\u5217\u7684\u4e8c\u7ef4\u6570\u7ec4<\/p>\n

4\u3001\u5c06\u6570\u7ec4\u5199\u5165\u5230\u5355\u5143\u683c<\/strong><\/h1>\n

4.1\u3001\u4e8c\u7ef4\u6570\u7ec4\u5199\u5165<\/strong><\/p>\n

Sub test()\nDim arr, arr1(1 To 5, 1 To 1) ' \u52a1\u5fc5\u6ce8\u610farr1(5,1)\u7684\u5751\uff0c\u5176\u4ee3\u88686\u884c2\u5217\nDim x!\narr = Range(\"b2:c6\")\nFor x = 1 To 5\n arr1(x, 1) = arr(x, 1) * arr(x, 2)\nNext x\nRange(\"d2\").Resize(5) = arr1\nEnd Sub\n<\/pre>\n

4.2\u3001\u4e00\u7ef4\u6570\u7ec4\u5199\u5165<\/strong><\/p>\n

Sub test()\nDim arr, arr1(1 To 5)\nDim x!\narr = Range(\"b2:c6\")\nFor x = 1 To 5\n arr1(x) = arr(x, 1) * arr(x, 2)\nNext x\nRange(\"d2\").Resize(5) = Application.WorksheetFunction.Transpose(arr1)\nEnd Sub\n<\/pre>\n

\u8bf4\u660e<\/strong><\/p>\n

\u4e00\u7ef4\u6570\u7ec4\u9ed8\u8ba4\u662f\u884c\u7ed3\u6784\uff0c\u5982\u679c\u9700\u8981\u5217\u7ed3\u6784\uff0c\u9700\u8981\u4f7f\u7528Transpose\u51fd\u6570<\/p>\n

4.3\u3001\u6570\u7ec4\u90e8\u5206\u5199\u5165<\/strong><\/p>\n

Sub test()\nDim arr, arr1(1 To 50)\nDim x!\narr = Range(\"b2:c6\")\nFor x = 1 To 5\n arr1(x) = arr(x, 1) * arr(x, 2)\nNext x\nRange(\"d2\").Resize(5) = Application.WorksheetFunction.Transpose(arr1)\nEnd Sub\n<\/pre>\n

\u8bf4\u660e<\/strong><\/p>\n

1\u3001\u6570\u7ec4\u7684\u6709\u6548\u6570\u636e\u4e0d\u80fd\u5c11\u4e8e\u5b58\u50a8\u5355\u5143\u683c\u6570\u91cf\uff0c\u5982\u4e0a\u4f8b\u4e2d\uff0c\u6570\u7ec4\u5927\u5c0f\u4e3a50\u4e2a\uff0c\u6709\u6548\u6570\u636e5\u4e2a\uff0c\u6240\u9700\u8981\u5b58\u50a8\u7684\u5355\u5143\u683c\u4e3a5\u4e2a\uff0c\u5219\u53ef\u6b63\u5e38\u5b58\u5165\u3002<\/p>\n

2\u3001arr = range()\uff0c\u53ea\u4f1a\u8bb2range\u7684value\u5c5e\u6027\u8d4b\u503c\u7ed9\u6570\u7ec4arr\uff0c\u5982\u679c\u9700\u8981\u88c5\u8f7drange\u5bf9\u8c61\u672c\u8eab\uff0c\u9700\u4f7f\u7528set arr = range()\u8bed\u53e5\u3002<\/p>\n

5\u3001\u6570\u7ec4\u7684\u6392\u5e8f<\/strong><\/h1>\n

\u6570\u7ec4\u4f7f\u7528\u7f16\u53f7\u6392\u5e8f\u7684\uff0c\u53ef\u4ee5\u901a\u8fc7Lbound\u65b9\u6cd5\u548cUbound\u65b9\u6cd5\u83b7\u53d6\u6570\u7ec4\u7684\u4e0a\u4e0b\u9650\u7f16\u53f7<\/p>\n

Lbound(\u6570\u7ec4)\u53ef\u4ee5\u83b7\u53d6\u6570\u7ec4\u7684\u6700\u5c0f\u7f16\u53f7(\u4e0b\u6807)<\/p>\n

Ubound(\u6570\u7ec4)\u53ef\u4ee5\u83b7\u53d6\u6570\u7ec4\u7684\u6700\u5927\u7f16\u53f7(\u4e0a\u6807)<\/p>\n

Ubound(\u6570\u7ec4,1)\u83b7\u5f97\u4e8c\u7ef4\u6570\u7ec4\u7684\u884c\u4e0a\u6807<\/p>\n

Ubound(\u6570\u7ec4,2)\u83b7\u5f97\u4e8c\u7ef4\u6570\u7ec4\u7684\u5217\u4e0a\u6807<\/p>\n

Lbound\u53cd\u4e4b<\/p>\n

\u793a\u4f8b<\/strong><\/p>\n

Sub test()\nDim arr\nDim x!\narr = Range(\"a2:d5\")\nFor x = 1 to Ubound(arr,1)\n\u200b\nNext x\nEnd Sub\n<\/pre>\n

6\u3001\u52a8\u6001\u6570\u7ec4\u7684\u52a8\u6001\u6269\u5145<\/strong><\/h1>\n

\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\u6765\u6269\u5145\u539f\u5148\u7684\u6570\u7ec4\uff0c\u5e76\u4e14\u4fdd\u7559\u539f\u6765\u7684\u6570\u636e<\/p>\n

ReDim Preserve arr()<\/p>\n

ReDim Preserve\u6539\u53d8\u6700\u672b\u7ef4\u7684\u4e0a\u754c\uff0c\u4e14\u4e0d\u80fd\u6539\u53d8\u6570\u7ec4\u7ef4\u6570\u3002\u5982\u679c\u6539\u53d8\u4e0b\u6807\uff0c\u5219\u51fa\u9519\u3002<\/p>\n

\u4e00\u7ef4\u6570\u7ec4\u52a8\u6001\u6269\u5145\u529e\u6cd5\uff1a\u76f4\u63a5\u6269\u5145<\/p>\n

\u591a\u7ef4\u6570\u7ec4\u52a8\u6001\u6269\u5145\u529e\u6cd5\uff1a\u9010\u4e2a\u7ef4\u5ea6\u6269\u5145\uff0c\u4e2d\u95f4\u4f7f\u7528\u8f6c\u7f6e\u51fd\u6570\u8f6c\u6362\u7ef4\u5ea6\u3002<\/p>\n

\u6280\u5de7<\/strong><\/p>\n

\u5982\u679c\u53ef\u4ee5\u4f30\u7b97\u51fa\u52a8\u6001\u6570\u7ec4\u7684\u4e0a\u754c\uff0c\u5219\u53ef\u4ee5\u8bbe\u5b9a\u4e00\u4e2a\u4e0a\u754c\u5f88\u5927\u7684\u6570\u7ec4\uff0c\u7136\u540e\u6b63\u5e38\u64cd\u4f5c\uff0c\u6700\u540e\u622a\u53d6\u6709\u6548\u6570\u636e\u90e8\u5206\u3002<\/p>\n

7\u3001\u5f3a\u5236\u58f0\u660e\u6570\u7ec4\u4e0b\u6807<\/strong><\/h1>\n

\u6570\u7ec4\u7684\u4e0b\u6807\u9664\u4e86\u5728\u751f\u547d\u65f6\u89c4\u5b9a\u4e0b\u754c\uff08\u5982dim arr(1 to 5)\uff09\u4e4b\u5916\uff0c\u53ef\u4ee5\u4f7f\u7528\u5f3a\u5236\u751f\u547d\u6765\u6539\u53d8\u6570\u7ec4\u4e0b\u754c\u4e0d\u4ee50\u5f00\u59cb<\/p>\n

Option Base \u6570\u5b57<\/p>\n

\u793a\u4f8b<\/p>\n

Option Base 1 ' \u5f3a\u5236\u58f0\u660e\u6570\u7ec4\u4e0b\u754c\u4ece1\u5f00\u59cb\n<\/pre>\n

8\u3001\u5faa\u73af\u901f\u5ea6\u3000<\/strong><\/h1>\n

\u5728\u5faa\u73af\u6570\u7ec4\u65f6\uff0c\u4f7f\u7528for each\u5faa\u73af\u7ed3\u6784\u6bd4for next\u7ed3\u6784\u8981\u5feb\uff0c\u4f46\u4e0d\u8db3\u4e4b\u5904\u662ffor each\u4e0d\u652f\u6301\u4fee\u6539\u6570\u7ec4\u7684\u5143\u7d20\uff08\u5373\u4fee\u6539\u8bed\u53e5\u65e0\u6548\uff09<\/p>\n

\u793a\u4f8b<\/strong><\/p>\n

for each\u65e0\u6cd5\u4fee\u6539\u6570\u7ec4\u5143\u7d20<\/p>\n

Sub test()\nDim arr, element\narr = [a1:b12]\nFor Each element In arr\n element = element - 1\nNext element\nEnd Sub\n<\/pre>\n

\u7ed3\u679c\uff1aa1:b12\u5355\u5143\u683c\u503c\u4e0d\u53d8\u3002<\/p>\n

\u6ce8\u610f<\/strong><\/p>\n

\u65e0\u8bba\u6570\u7ec4\u662f\u4ec0\u4e48\u6570\u636e\u7c7b\u578b\uff0cfor each\u7684\u5faa\u73af\u53d8\u91cf\u5fc5\u987b\u662fVariant\u7c7b\u578b\u3002<\/p>\n

9\u3001\u6e05\u7a7a\u6570\u7ec4<\/strong><\/h1>\n

Erase \u65b9\u6cd5<\/strong><\/p>\n

\u6e05\u7a7a\u6570\u7ec4<\/p>\n

\u8bed\u6cd5<\/strong><\/p>\n

Erase \u6570\u7ec4\u540d\u79f0<\/p>\n

10\u3001\u51fd\u6570\u4e0e\u6570\u7ec4<\/strong><\/h1>\n

10.1\u3001\u53ef\u4ee5\u4f7f\u7528VBA\u51fd\u6570\u8ba1\u7b97\u6570\u7ec4,\u5982VBA.Filter\u51fd\u6570<\/strong><\/p>\n

10.2\u3001\u53ef\u4ee5\u4f7f\u7528\u5de5\u4f5c\u8868\u51fd\u6570\u8ba1\u7b97\u6570\u7ec4\uff0c\u5982Application.Max(arr1)<\/strong><\/p>\n

11\u3001\u6570\u7ec4\u4e0e\u5355\u5143\u683c\u683c\u5f0f<\/strong><\/h1>\n

\u53d6\u5f97\u5355\u5143\u683c\u7684\u5730\u5740\uff0c\u7136\u540e\u653e\u5165\u5230Range\u4e2d\uff0c\u7136\u540e\u8bbe\u7f6eRange\u7684\u5355\u5143\u683c\u5c5e\u6027<\/p>\n

\u5176\u4e2d\u6ce8\u610fRange\u4e2d\u7684\u5b57\u7b26\u957f\u5ea6<=255\u3002<\/p>\n

\u6280\u5de7<\/strong><\/p>\n

\u56e0Range\u6709255\u4e2a\u5b57\u7b26\u9650\u5236\uff0c\u6240\u4ee5\u5728\u83b7\u5f97\u5355\u5143\u683c\u5730\u5740\u65f6\uff0c\u53ef\u4ee5\u53ea\u83b7\u5f97\u5355\u5143\u683c\u7684\u884c\u53f7\uff08\u540c\u4e00\u4e2aRagne\u53ef\u4ee5\u653e\u7f6e\u66f4\u591a\u7684\u7ed3\u679c\uff0c\u63d0\u9ad8\u8fd0\u884c\u901f\u5ea6\uff09\uff0c\u7136\u540e\u4f7f\u7528Application.Intersect()\u65b9\u6cd5\u83b7\u53d6\u884c\u5217\u7684\u4ea4\u96c6\uff0c\u4ece\u800c\u5b9a\u4f4d\u5230\u76ee\u6807\u5355\u5143\u683c\u3002<\/p>\n

12\u3001\u6392\u5e8f\u7b97\u6cd5<\/strong><\/h1>\n

12.1\u3001\u5192\u6ce1\u6392\u5e8f<\/strong><\/p>\n

\u6bcf\u4e00\u4e2a\u6570\u5b57\u4e0e\u5176\u4f4d\u7f6e\u4e4b\u540e\u7684\u6240\u6709\u6570\u5b57\u8fdb\u884c\u6bd4\u8f83\uff0c\u5982\u5927\u4e8e\u540e\u9762\u7684\u6570\u5b57\uff0c\u4f4d\u7f6e\u4e0d\u53d8\uff0c\u5982\u5c0f\u4e8e\u540e\u9762\u7684\u6570\u5b57\uff0c\u53cc\u65b9\u4e92\u6362\u3002<\/p>\n

\u793a\u4f8b<\/strong><\/p>\n

Sub \u5192\u6ce1\u6392\u5e8f()\nDim arr,temp,x,y,k\narr = Range(\"a1:a10\")\nFor x = 1 To Ubound(arr) - 1\n For y = x + 1 To Ubound(arr)\n If arr(x,1) > arr(y,1) Then\n temp = arr(x,1)\n arr(x,1) = arr(y,1)\n arr(y,1) = temp\n End If\n Next y\nNext x\nEnd Sub\n<\/pre>\n

12.2\u3001\u9009\u62e9\u6392\u5e8f<\/strong><\/p>\n

\u4ece\u540e\u5f80\u524d\u5faa\u73af\uff0c\u6bcf\u4e00\u4e2a\u6570\u5b57\u4e0e\u4f4d\u7f6e\u4e4b\u524d\u7684\u6700\u5927\u503c\u8fdb\u884c\u6bd4\u8f83\u4e92\u6362\u3002<\/p>\n

\u9009\u62e9\u6392\u5e8f\u6bd4\u5192\u6ce1\u6392\u5e8f\u901f\u5ea6\u5feb<\/p>\n

\u793a\u4f8b<\/strong><\/p>\n

Sub \u9009\u62e9\u6392\u5e8f()\nDim arr,temp,x,y,iMax,k,k1,k2\narr = Range(\"a1:a10)\nFor x = Ubound(arr) To 1+1 Step -1\n iMax = 1\n For y = 1 To x\n If arr(y,1) > arr(iMax,1) Then iMax = y\n Next y\n temp = arr(iMax,1)\n arr(iMax,1) = arr(x,1)\n arr(x,1) = temp\nNext x\nEnd Sub\n<\/pre>\n

13.3\u3001\u63d2\u5165\u6392\u5e8f<\/strong><\/p>\n

\u4ece\u6570\u7ec4\u7684\u7b2c2\u4e2a\u5143\u7d20\u5f00\u59cb\u5f80\u540e\u5faa\u73af\uff0c\u6bcf\u4e00\u4e2a\u6570\u5b57\u4e0e\u5b83\u4e4b\u524d\u7684\u6570\u5b57\u6bd4\u8f83\uff0c\u5982\u679c\u4f4d\u7f6e\u4e4b\u524d\u7684\u6570\u5b57\u5927\u4e8e\u5176\uff0c\u5219\u5c06\u8be5\u6570\u5b57\u4e0e\u5176\u4e92\u6362\uff0c\u653e\u7f6e\u5176\u540e\uff0c\u5426\u5219\uff0c\u4f4d\u7f6e\u4e0d\u53d8\u3002<\/p>\n

13.4\u3001\u5e0c\u5c14\u6392\u5e8f<\/strong><\/p>\n

\u5f15\u7528\u201c<\/p>\n

\u5e0c\u5c14\u6392\u5e8f\u5bf9 \u672a\u6392\u5e8f\u6570\u636e\u7684\u987a\u5e8f \u4e0d\u654f\u611f\uff0c\u867d\u7136\u5e73\u5747\u800c\u8a00\u901f\u5ea6\u6bd4\u5feb\u901f\u6392\u5e8f\u6162\u4e00\u500d\u5de6\u53f3<\/p>\n

\u4f46\u662f\u5374\u5b89\u5168\u5f88\u591a\uff0c\u6ca1\u6709\u5feb\u901f\u6392\u5e8f\u7684\u5806\u6808\u6ea2\u51fa\u95ee\u9898\uff0c\u6ca1\u6709\u9000\u5316\u4e3aO(n^2)\u7684\u95ee\u9898<\/p>\n

\u800c\u4e14\u5bf9\u6bd4\u8f83\u6709\u5e8f\u7684\u8f93\u5165\u6570\u636e\uff0c\u91cd\u590d\u5ea6\u9ad8\u7684\u6570\u636e\uff0c\u901f\u5ea6\u8fdc\u8fdc\u8d85\u8fc7\u5feb\u901f\u6392\u5e8f\u3002<\/p>\n

\u6240\u4ee5\u8fd8\u662f\u4e00\u4e2a\u5f88\u4e0d\u9519\u7684\u6392\u5e8f\u7b97\u6cd5\uff0c\u5c24\u5176\u662f\u8fd8\u53ef\u4ee5\u8ddf\u5feb\u901f\u6392\u5e8f\u7ed3\u5408\uff0c\u5927\u5927\u964d\u4f4e\u5feb\u901f\u6392\u5e8f\u7684\u9012\u5f52\u6b21\u6570\u3002<\/p>\n

\u5e0c\u5c14\u6392\u5e8f\u5b9e\u73b0\u8d77\u6765\u6bd4\u4e5f\u975e\u5e38\u7b80\u5355\u3002\u5c31\u662f\u591a\u91cd\u5faa\u73af\u6bd4\u8f83\u4e0d\u597d\u770b\u800c\u5df2\u3002<\/p>\n

\u9644\u4ef6\u7684\u5e0c\u5c14\u6392\u5e8f\u5df2\u7ecf\u505a\u6210\u4e00\u4e2a\u5b50\u7a0b\u5e8f\uff0c\u5728\u4efb\u4f55\u7a0b\u5e8f\u76f4\u63a5\u8c03\u7528\u5373\u53ef\u3002<\/p>\n

\u5e0c\u5c14\u6392\u5e8f\u7684\u901f\u5ea6\u5173\u952e\u662f\uff1a\u9009\u62e9\u5408\u9002\u7684h\u5e8f\u5217\uff0c\u4e5f\u5c31\u662f\u6bcf\u6b21\u5faa\u73af\u8df3\u8fc7\u591a\u5c11\u4e2a\u6570\u636e\u6765\u4ea4\u6362<\/p>\n

\u518d\u5570\u55e6\u4e00\u4e0bh\u5e8f\u5217\u7684\u95ee\u9898\uff0c\u5047\u8bbe\u5df2\u7ecf\u77e5\u9053\u5e0c\u5c14\u6392\u5e8f\u4f7f\u7528\u7684h\u5e8f\u5217\u662f\u600e\u4e48\u56de\u4e8b<\/p>\n

\u90a3\u4e48\u6bd4\u8f83\u5e38\u7528\u7684\uff0c\u5df2\u7ecf\u7ecf\u8fc7\u8ba1\u7b97\u673a\u754c\u7684\u5927\u5e08\u9a8c\u8bc1\uff0c\u7edd\u5bf9\u6162\u4e0d\u5230\u54ea\u91cc\u53bb\u7684h\u5e8f\u5217\uff0c\u6709\u4ee5\u4e0b\u51e0\u79cd <\/p>\n

1 h1=1, \u7136\u540e\u5f80\u540e\u6bcf\u4e2ah\u90fd\u7b49\u4e8e 3h+1<\/p>\n

2 h1=1, \u7136\u540e\u5f80\u540e\u6bcf\u4e2ah\u90fd\u7b49\u4e8e 2.25h+1\uff0c\u53d6\u6574<\/p>\n

3 \u8fd9\u4e2a\u6bd4\u8f83\u590d\u6742, h1\u5f53\u7136\u4e5f\u662f1\uff0ch2\u5f80\u540e\u5219\u7528\u516c\u5f0f\u8ba1\u7b97\u51fa\u6765\uff0c\u5047\u5982<\/p>\n

[n]\u662f\u5355\u6570,\u90a3\u4e48 h[n] =82^n-62^((n+1)\/2)+1<\/p>\n

[n]\u662f\u53cc\u6570,\u90a3\u4e48 h[n] =92^n-92^(n\/2)+1<\/p>\n

\u4e5f\u5c31\u662f\u8bf4 h\u5e8f\u5217 = {1,,5,19,41,109,209,505,929,........}<\/p>\n

\u8fd9\u4e00\u4e2a\u5e8f\u5217\u5df2\u7ecf\u88ab\u6570\u5b66\u8bc1\u660e\u4e3aO(n^1.25)\u7684\u589e\u957f\u9636\uff0c\u8bc1\u660e\u8fc7\u7a0b\u5219\u4f30\u8ba1\u6211\u5b8c\u5168\u770b\u4e0d\u61c2\u3002\u3002\u3002\u3002\u3002\u3002<\/p>\n

4 \u6211\u81ea\u5df1\u7684\u53d1\u73b0\uff0c\u7531\u4e8eh\u5e8f\u5217\u4e00\u822c\u6765\u8bf4\uff0c\u524d\u540e\u4e24\u4e2ah\u662f\u4e92\u8d28\u7684\u4f1a\u6bd4\u8f83\u597d\uff0c\u800c\u6211\u53c8\u53d1\u73b03\u53f7\u5e8f\u5217\u5e76\u4e0d\u5b8c\u5168\u662f\u8d28\u6570<\/p>\n

\u4e8e\u662f\u5c31\u628a\u6240\u6709\u7684\u975e\u8d28\u6570\u6362\u4e3a\u6700\u63a5\u8fd1\u7684\u8d28\u6570\uff0c\u7ed3\u679c\u53d1\u73b0\u53c8\u5feb\u4e863%\u5de6\u53f3\uff0cyeah\uff01 \u8fd9\u4e5f\u662f\u6211\u7684\u9644\u4ef6\u4ee3\u7801\u6700\u7ec8\u91c7\u7528\u7684h\u5e8f\u5217<\/p>\n

\u8bba\u575b\u4ee5\u524d\u53d1\u8fc7\u7684\u5e0c\u5c14\u6392\u5e8f\u8d34\uff0c\u8c8c\u4f3c\u90fd\u662f\u7528 h[n] = 2^n - 1\uff0c\u6216\u8005\u5e72\u8106\u5c31\u662f h[n] = 2^n<\/p>\n

\u524d\u8005\u8c8c\u4f3c\u4e5f\u662fO(n^1.25)\uff0c\u4f46\u662f\u660e\u663e\u6bd4\u524d\u9762\u56db\u4e2a\u5e8f\u5217\u6162\u4e00\u5927\u622a<\/p>\n

\u540e\u8005\u5219\u662f\u7b97\u6cd5\u53d1\u660e\u4eba\u5e0c\u5c14\u6700\u65e9\u63d0\u51fa\u7684\u5e8f\u5217\uff0c\u4f46\u662f\u5f88\u5feb\u5c31\u88ab\u8bc1\u660e\u662f\u4e2a\u975e\u5e38\u574f\u7684h\u5e8f\u5217\uff0c\u901f\u5ea6\u6162\u800c\u4e14\u5f88\u53ef\u80fd\u4f1a\u9000\u5316\u5230O(n^2)\uff0c\u6240\u4ee5\u4e0d\u5b9c\u91c7\u7528\u3002<\/p>\n

*************\u4ee5\u4e0b\u8ba8\u8bba\u5806\u6392\u5e8f<\/p>\n

\u5806\u6392\u5e8f\u7684\u901f\u5ea6\uff0c\u4e00\u822c\u6bd4\u5e0c\u5c14\u6392\u5e8f\u616210%\u523020%<\/p>\n

\u57fa\u672c\u7684\u5806\u6392\u5e8f\uff0c\u901f\u5ea6\u5f88\u6162\uff0c\u539f\u56e0\u662f\u6bcf\u6b21\u4ea4\u6362\u6700\u5927\u7684\u5143\u7d20\u5230\u6570\u7ec4\u672b\u5c3e\uff0c\u8fd9\u65f6\u5019\u6570\u7ec4\u672b\u5c3e\u7684\u5143\u7d20\u5c06\u4ea4\u6362\u5230\u5806\u9876<\/p>\n

\u518d\u6b21\u628a\u8fd9\u4e2a\u5143\u7d20\u653e\u8fdb\u5806\u91cc\u9762\uff0c\u5c31\u662f\u628a\u4e00\u4e2a\u5f88\u5c0f\u7684\u5143\u7d20\u538b\u8fdb\u5806\uff0c\u6bd4\u8f83\u7684\u6b21\u6570\u5c06\u4f1a\u5f88\u591a\uff0c\u51e0\u4e4e\u5fc5\u5b9a\u662flog(n)<\/p>\n

\u6240\u4ee5\u91c7\u7528Floyd\u7684\u7b97\u6cd5\uff0c\u5148\u628a\u8fd9\u4e2a\u5f88\u5c0f\u7684\u5806\u9876\u5143\u7d20\u538b\u5230\u6700\u5e95\u5c42\uff0c\u7136\u540e\u518d\u4e0a\u5347\u5230\u5408\u9002\u4f4d\u7f6e\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u52a0\u5feb\u4e00\u500d<\/p>\n

\u9644\u4ef6\u662f\u56db\u4e2a\u5806\u6392\u5e8f\u7b97\u6cd5\uff1a\u5206\u522b\u662f\u6700\u57fa\u672c\u7684\u5806\u6392\u5e8f\uff0c\u4e09\u5143\u5206\u53c9\u7684\u5806\u6392\u5e8f\uff0c\u6700\u57fa\u672c\u5806\u6392\u5e8f\uff0b\u5148\u6c89\u5e95\u518d\u4e0a\u5347\uff08\u6700\u4f73\u7248\u672c\uff09\uff0c\u4e09\u5143\u7684\u5806\u6392\u5e8f+\u5148\u6c89\u5e95\u518d\u4e0a\u5347<\/p>\n

\u53ef\u4ee5\u770b\u51fa\uff0c\u57fa\u672c\u4e09\u5143\u5806\u6bd4\u57fa\u672c\u4e24\u5143\u5806\u5feb\uff0c\u800c\u4e14\u5148\u6c89\u5e95\u518d\u4e0a\u5347\u7684\u505a\u6cd5\uff0c\u5bf9\u4e09\u5143\u5806\uff0c\u4e24\u5143\u5806\u90fd\u6709\u6548<\/p>\n

\u800c\u4ee4\u4eba\u60ca\u5947\u7684\u662f\uff1a\u4e24\u5143\u5806\u5148\u6c89\u5e95\u518d\u4e0a\u5347\uff0c\u6bd4\u4e09\u5143\u5806\u5148\u6c89\u5e95\u518d\u4e0a\u5347\u66f4\u5feb\uff0c\u53ef\u80fd\u662f\u4e09\u5143\u5806\u63d0\u5347\u4e09\u4e2a\u53f6\u5b50\u7684\u6700\u5927\u5143\u7d20\uff0c\u5176\u6bd4\u8f83\u6b21\u6570\u592a\u591a<\/p>\n

\u8fd9\u5012\u662f\u4ef6\u597d\u4e8b\uff0c\u56e0\u4e3a\u4e24\u5143\u5806\u7684\u4ee3\u7801\u6bd4\u8f83\u7b80\u5355\uff0c\u800c\u4e14\u901f\u5ea6\u66f4\u5feb\uff0c\u597d\u6781\u4e86\u3002<\/p>\n

\u5806\u6392\u5e8f\u6700\u5927\u7279\u70b9\uff1a\u53ef\u4ee5\u8fc5\u901f\u53d6\u51fa\u6700\u5927\u503c\uff08\u6216\u8005\u6700\u5c0f\u503c\uff09\uff0c\u5982\u679c\u662f\u6c42100\u4e07\u5143\u7d20\u7684\u524d1\u4e07\u4e2a\uff0c\u90a3\u4e48\u5806\u6392\u5e8f\u80af\u5b9a\u662f\u6700\u5feb\u7684\u3002<\/p>\n

\u56e0\u4e3a\u53ea\u9700\u8981\u5bf91\u4e07\u4e2a\u5143\u7d20\u8fdb\u884c\u5806\u5904\u7406\uff0c\u800c\u5176\u5b83\u6392\u5e8f\u65b9\u6cd5\u9700\u8981\u5bf9100\u4e07\u4e2a\u5143\u7d20\u6392\u5e8f\u3002<\/p>\n

\u55ef\u3002\u3002\u3002\u3002\u3002\u3002\u4e5f\u8bb8\u5feb\u901f\u6392\u5e8f\u4e5f\u53ef\u4ee5\u7f29\u5c0f\u6392\u5e8f\u7684\u8303\u56f4\uff0c\u5982\u8d85\u8fc71\u4e07\u7684\u90e8\u5206\u5c31\u4e0d\u518d\u9012\u5f52\u6392\u5e8f\uff0c\u4e5f\u8bb8\u8fd8\u6709\u53ef\u80fd\u6bd4\u5806\u6392\u5e8f\u5feb\u3002<\/p>\n

*************\u4ee5\u4e0b\u8ba8\u8bba\u5feb\u901f\u6392\u5e8f<\/p>\n

\u4f5c\u4e3a\u4e00\u822c\u800c\u8a00\u6700\u9ad8\u901f\u7684\u6392\u5e8f\u7b97\u6cd5\uff0c\u5feb\u901f\u6392\u5e8f\u65e2\u8ba9\u4eba\u9ad8\u5174\uff0c\u53c8\u8ba9\u4eba\u4e0d\u653e\u5fc3<\/p>\n

\u9ad8\u5174\u7684\u662f\uff1a\u901f\u5ea6\u771f\u7684\u5feb\u591a\u4e86<\/p>\n

\u4e0d\u653e\u5fc3\u7684\u662f\uff1a\u78b0\u5230\u67d0\u4e9b\u5e8f\u5217\uff0c\u6392\u5e8f\u65f6\u95f4\u4f1a\u6076\u5316\u5230\u65e0\u6cd5\u63a5\u53d7\u7684O(n^2)<\/p>\n

\u9644\u4ef6\u662f\u516d\u4e2a\u7248\u672c\u7684\u5feb\u901f\u6392\u5e8f\uff0c\u57fa\u672c\u4e0a\u5305\u62ec\u4e86\u5bf9\u5feb\u901f\u6392\u5e8f\u8fdb\u884c\u4f18\u5316\u7684\u5404\u79cd\u6280\u5de7<\/p>\n

\u4f5c\u4e3a\u5bf9\u6bd4\uff0c\u7b2c\u4e00\u4e2a\u6700\u6162\u901f\u6700\u4e0d\u53ef\u9760\u7684\u7248\u672c\u662f\u4ece\u8bba\u575b\u5e16\u201c\u4e03\u79cd\u6392\u5e8f\u7b97\u6cd5\u201d\u6284\u8fc7\u6765\u7684<\/p>\n

\u5176\u4f59\u4e94\u4e2a\u7248\u672c\u662f\u6211\u81ea\u5df1\u7684\u4f5c\u54c1<\/p>\n

\u7b80\u800c\u8a00\u4e4b\uff0c\u5feb\u901f\u6392\u5e8f\u7684\u5f0a\u7aef\u662f<\/p>\n

1 \u9012\u5f52\u6b21\u6570\u592a\u591a\uff0c\u4f1a\u5bfc\u81f4\u5806\u6808\u7a7a\u95f4\u6ea2\u51fa\u3002 <\/p>\n

\u89e3\u51b3\u529e\u6cd5\uff1a\u5bf9\u5c0f\u4e8e\u4e00\u5b9a\u6570\u91cf\u7684\u5143\u7d20\u8fdb\u884c\u76f4\u63a5\u63d2\u5165\u6392\u5e8f\uff0c\u5e0c\u5c14\u6392\u5e8f\uff0c\u800c\u4e0d\u662f\u7559\u7ed9\u4e0b\u4e00\u5c42\u7684\u9012\u5f52\u5feb\u901f\u6392\u5e8f<\/p>\n

2 \u6bcf\u6b21\u5212\u5206\u7684\u67a2\u7ebd\u503c\u9009\u53d6\u4e0d\u5f53\uff0c\u5c31\u4f1a\u5927\u5927\u5f71\u54cd\u901f\u5ea6<\/p>\n

\u89e3\u51b3\u529e\u6cd5\uff1a\u7528\u5e73\u5747\u503c\uff0c\u968f\u673a\u503c\u7b49\u7b49\u65b9\u5f0f\u6765\u51b3\u5b9a\u67a2\u7ebd\u503c\uff0c\u4f46\u662f\u65e0\u6cd5\u4fdd\u8bc1\u4e00\u5b9a\u4e0d\u4f1a\u51fa\u73b0\u901f\u5ea6\u9000\u5316\u7684\u73b0\u8c61<\/p>\n

\u8fdb\u4e00\u6b65\u89e3\u51b3\u65b9\u6cd5\uff1a\u5148\u7528\u5feb\u901f\u6392\u5e8f\uff0c\u7136\u540e\u5982\u679c\u8d85\u8fc7\u4e00\u5b9a\u65f6\u95f4\uff0c\u6216\u8005\u9012\u5f52\u4e00\u5b9a\u6b21\u6570\u540e\u8fd8\u6ca1\u5b8c\u6210\uff0c\u5c31\u5b8c\u5168\u8f6c\u4e3a\u5e0c\u5c14\u6392\u5e8f\u3002<\/p>\n

\u7efc\u5408\u800c\u8bba\uff0c\u6211\u4e2a\u4eba\u89c9\u5f97\u8fd8\u662f\u5e0c\u5c14\u6392\u5e8f\u6700\u53ef\u9760\uff0c\u5806\u6392\u5e8f\u7531\u4e8e\u6bcf\u6b21\u90fd\u53d6\u51fa\u6700\u5927\u503c\u7684\u7279\u70b9\uff0c\u6709\u4e9b\u65f6\u5019\u662f\u975e\u5b83\u4e0d\u53ef\uff01<\/p>\n

\u5feb\u901f\u6392\u5e8f\u5355\u7eaf\u7528\u539f\u59cb\u7248\u672c\uff0c\u662f\u4e00\u4e2a\u53c8\u6162\u53c8\u5371\u9669\u7684\u7b97\u6cd5\uff0c\u5b8c\u5168\u6ca1\u6709\u4efb\u4f55\u4ef7\u503c<\/p>\n

\u6539\u826f\u4ee5\u540e\u901f\u5ea6\u6781\u597d\uff0c\u4f46\u4e0d\u80fd\u5b8c\u5168\u653e\u5fc3\uff0c\u8f85\u4ee5\u5e0c\u5c14\u6392\u5e8f\u624d\u662f\u738b\u9053\u3002<\/p>\n

\u8865\u5145\u6c49\u5b57\u7684\u6392\u5e8f\u65b9\u5f0f\uff1a<\/p>\n

Excel\u672c\u8eab\u7684sort\u65b9\u6cd5\uff0c\u6709\u4e24\u79cd\u6c49\u5b57\u6392\u5e8f\u65b9\u5f0f<\/p>\n

\u540d\u79f0 \u503c \u63cf\u8ff0 <\/p>\n

xlPinYin 1 \u6309\u5b57\u7b26\u7684\u6c49\u8bed\u62fc\u97f3\u987a\u5e8f\u6392\u5e8f\u3002\u8fd9\u662f\u9ed8\u8ba4\u503c\u3002 <\/p>\n

xlStroke 2 \u6309\u6bcf\u4e2a\u5b57\u7b26\u7684\u7b14\u5212\u6570\u6392\u5e8f\u3002 <\/p>\n

VBA\u91cc\u9762\uff0c\u5b57\u7b26\u4e32\u6bd4\u5927\u5c0f\u4e5f\u6709\u4e24\u79cd\u65b9\u5f0f<\/p>\n

option compare binary \u5bf9\u5e94\u6309\u7b14\u753b\u6570\u6392\u5e8f\uff08\u9ed8\u8ba4\u503c\uff09<\/p>\n

option compare text \u5bf9\u5e94\u6309\u62fc\u97f3\u6392\u5e8f\uff0c\u901f\u5ea6\u5927\u6982\u6162\u4e00\u500d\u5427<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"Excel-VBA\uff1a14\u3001\u6570\u7ec4\u5355\u5143\u683c\u548c\u5185\u5b58\u5982\u679c\u6570\u636e\u5b58\u653e\u518d\u5355\u5143\u683c\u4e2d\uff0c\u7cfb\u7edf\u8ba1\u7b97\u9700\u8981\u4e24\u6b65\uff1a1\uff0c\u63d0\u53d6\u6570\u636e\uff0c\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d\uff1b2\u3001\u8fd0\u7b97\u5185\u5b58\u4e2d\u7684\u6570...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[82],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/676"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=676"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/676\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=676"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=676"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=676"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}