EXCEL中用VBA複製整行,EXCEL中怎麼用VBA抽取整行資料?

2022-02-10 07:19:50 字數 848 閱讀 3847

1樓:匿名使用者

用 vlookup 函式。到excel幫助中學習ta的用法。

2樓:太極健

這裡假設表1的資料在a:h列

用函式可在表二的b1輸入公式如下,公式右拉完成(a1輸入序號)

=vlookup($a1,sheet1!$a:$h,column(),0)

如果用vba實現,不管表1資料有幾列,整行復制。**如下:

private sub worksheet_change(byval target as range)

if target.column = 1 and target.count = 1 then

with sheets("sheet1")

for x = 1 to .range("a65536").end(xlup).row

if .cells(x, 1) = target.value then

.rows(x).copy target.rows

exit sub

end if

next x

end with

end if

end sub

把這**放到表2的**編輯框中即可實現你要的結果

excel中怎麼用vba抽取整行資料?

3樓:匿名使用者

問題是 你要 怎麼複製,

比如你修改 b1 發票號, 而 sheet2 原有內容是 清除掉,只顯示新的發票號內容,

還是 在 原有內容 下面接著新增 ?

需要寫 發 檔案 [email protected] ,只留這2個sheet 即可

如何在excel中用巨集(VBA)實現VLOOKUP的功能

function myvlookup val,rg as range,n as integer,f as boolean arr rg if f then for i ubound arr to 1 step 1if val arr i,1 thenmyvlookup arr i,n end fun...

excel裡面用vba新增空白行

sub insert dim i as long for i range a65536 end xlup row to 2 step 1 終止行到起始行 rows i resize 3 insert 3 為要插入的行數 next end sub sub insert dim i as long fo...

在excel中如何使用vba的巨集

保護公式可以這樣 選擇不需要保護 需要錄入內容 的單元格,設定單元格屬性,最後一個 保護 卡里面的 鎖定 取消,其它那些沒有取消鎖定的有公式的單元格自然是鎖定狀態。下一步是在工具 審閱 新版本 或者 工具 選單 舊版本 裡面選擇 保護工作表 設定一個密碼後確認。完成這兩步之後,鎖定的單元格內容就無法...