excel巨集 終極版

2021-06-27 10:36:28 字數 3054 閱讀 7826

private sub commandbutton1_click()

'sheet1=q20.list;sheet2=q20trim.list;sheet3=源資料表_副本

'新建sheet4=批量合成+刪除空行+變成m

'最終資料存於sheet3列pqr

'批量合成

dim s as integer

s = textbox1.text

for i = 1 to s

sheet4.cells(i, 1) = mid(sheet1.cells(i, 1), 5, 5)

sheet4.cells(i, 4) = mid(sheet2.cells(i, 1), 5, 5)

sheet4.cells(i, 2) = sheet1.cells(i, 2)

sheet4.cells(i, 5) = sheet2.cells(i, 2)

next

'合併計算

for i = 1 to s

for j = 1 to i - 1

if sheet4.cells(j, 1) = sheet4.cells(i, 1) then

sheet4.cells(i, 2) = sheet4.cells(i, 2) + sheet4.cells(j, 2)

sheet4.cells(j, 1) = ""

sheet4.cells(j, 2) = ""

end if

next

for j = i + 1 to s

if sheet4.cells(j, 1) = sheet4.cells(i, 1) then

sheet4.cells(i, 2) = sheet4.cells(i, 2) + sheet4.cells(j, 2)

sheet4.cells(j, 1) = ""

sheet4.cells(j, 2) = ""

end if

next

next

for i = 1 to s

for j = 1 to i - 1

if sheet4.cells(j, 4) = sheet4.cells(i, 4) then

sheet4.cells(i, 5) = sheet4.cells(i, 5) + sheet4.cells(j, 5)

sheet4.cells(j, 4) = ""

sheet4.cells(j, 5) = ""

end if

next

for j = i + 1 to s

if sheet4.cells(j, 4) = sheet4.cells(i, 4) then

sheet4.cells(i, 5) = sheet4.cells(i, 5) + sheet4.cells(j, 5)

sheet4.cells(j, 4) = ""

sheet4.cells(j, 5) = ""

end if

next

next

'資料合併

for i = 1 to s

for j = 1 to s

if sheet4.cells(j, 4) = sheet4.cells(i, 1) then

sheet4.cells(i, 3) = sheet4.cells(j, 5)

sheet4.cells(j, 4) = ""

sheet4.cells(j, 5) = ""

end if

next

next

'刪除空行

for i = 1 to s

if sheet4.cells(i, 1) = "" then

sheet4.rows(i).delete

end if

next

for i = 1 to s

if sheet4.cells(i, 1) = "" then

sheet4.rows(i).delete

end if

next

for i = 1 to s

if sheet4.cells(i, 1) = "" then

sheet4.rows(i).delete

end if

next

for i = 1 to s

if sheet4.cells(i, 1) = "" then

sheet4.rows(i).delete

end if

next

'變成m

for i = 1 to s / 2

sheet4.cells(i, 2) = sheet4.cells(i, 2) / 1000000

sheet4.cells(i, 3) = sheet4.cells(i, 3) / 1000000

next

'轉移到sheet3

for i = 1 to s / 2

for j = 3 to (s / 2 + 3)

if mid(sheet3.cells(j, 2), 5, 5) = sheet4.cells(i, 1) then

sheet3.cells(j, 16) = sheet4.cells(i, 2)

sheet3.cells(j, 16).numberformatlocal = "0.0_ "

sheet3.cells(j, 17) = sheet4.cells(i, 3)

sheet3.cells(j, 17).numberformatlocal = "0.0_ "

end if

next

next

'求百分比

sheet3.columns("r:r").numberformatlocal = "0.0%"

for i = 3 to (s / 2 + 3)

if sheet3.cells(i, 1) <> "" then

sheet3.cells(i, 18) = sheet3.cells(i, 17) / sheet3.cells(i, 16)

end if

next

end sub

頁面傳參終極版

頁面傳引數是一種比較常見的業務需求,根據實現原理及適用環境可以分為兩大類。在普通瀏覽器端常用的方法有如下幾種 1.利用url傳參 在頁面跳轉的時候通過設定window.location.href新增引數,在接收引數的頁面通過window.location.search獲取引數字串。傳送引數的頁面 w...

kewin 接小球終極版

import pygame import random 1.loading 初始化 pygame.init 2.視窗 dis分開 play玩 展示 screen width 960screen height 540screen pygame.display.set mode screen width...

六禕 Redis Redis終極版

nosql not only sql 不僅僅是sql,通常指的是非關係型的資料庫。mysql和oracle都是屬於關係型資料庫。redis是乙個開源的使用c語言編寫 支援網路 可基於記憶體亦可持久化的日誌型 key value資料庫,並提供多種語言的api。couchdb 是乙個開源的面向文件的資料...