Vba如何刪除整行並上移單元格,excel vba 刪除空白單元格所在的行

時間 2022-03-08 01:55:05

1樓:旬刖

按右鍵,選擇刪除,點選刪除,選擇刪除行

excel,點中某單元格,vba將這一行的整行資料上下移

2樓:平陽虎

自己將「某單元格單獨移動」的語句改為整行移動就行了。

3樓:匿名使用者

將如下**複製到sheet**中。

private sub worksheet_selectionchange(byval target as range)

if target.row > 1 then

dim clickcell as single

clickcell = target.row

rows(clickcell - 1 & ":" & clickcell - 1).insert shift:

=xldown, copyorigin:=xlformatfromleftorabove

rows(clickcell + 1 & ":" & clickcell + 1).cut destination:

=rows(clickcell - 1 & ":" & clickcell - 1)

rows(clickcell + 1 & ":" & clickcell + 1).delete

end if

end sub

excel中,怎麼用巨集把單元格為0的整行刪掉?內詳

4樓:小李無刀

刪除行的**:

range("1:1").delete

刪除行時,從頂上刪除是不行的(刪除後,總行號上移了呢),只能從底下刪除。所以全**是:

sub delrow()

for i=7531 to 1 step -1 '從最後一行開始往上判斷

if range("e" & i)=0 then range(i & ":" & i).delete 『如果等於0就刪除

next

end sub

5樓:匿名使用者

從最後一行開始判斷,逐行判斷,逐一刪除。

6樓:匿名使用者

要用巨集執行:就先錄製個巨集,然後用程式呼叫這個巨集。自動把0刪除

7樓:

篩選 e 列,把引數為 0 的篩選出來,然後選擇這些行並刪除之。

8樓:匿名使用者

sub 刪除0行()

'想把e1至e7531之間這段,如果之間這段有引數為0,就把整行刪掉dim j

j = 1

for i = 11 to 1 step -1if cells(i, 5) = 0 thensheets("sheet1").rows(i).deleteend if

next

end sub

9樓:匿名使用者

直接篩選就完了

巨集就巨集吧

10樓:匿名使用者

sub test()

i = 1

do while i <= 7531

if range("e" + cstr(i)) = 0 thenrows(i).delete

else

i = i + 1

end if

loop

end sub

excel vba 刪除空白單元格所在的行

11樓:匿名使用者

1、首先在開發工具中開啟vba編輯器。

2、在單元格區域當中輸入一些內容。

3、在vba編輯器中插入模組。

4、在模組當中輸入如下**,然後執行sub 清除空白資料行()dim i as longfor i=cells(1048576, 2).end(xlup).row to 3 step-1if cells(i, 3)="" then'如果單元格為cells(i,1).

entirerow.delete'符合條件的都刪除整行end ifnext'檢測下一個end sub。

5、用快捷鍵alt+f8調出執行巨集視窗,然後單擊「執行」按鈕,程式執行後第三列為空白之單元格所在行全部刪除。

12樓:大風吹大風吹大風吹

sub macro1()

dim i as integer '小於32,767用integer

'dim i as long '超過32,767用long

for i = [a20].end(1).row to 1 step -1 'a20到a1結束,步長 -1,就是每迴圈一次減1

if cells(i, 1) = "" then '判斷 i 行是否為空?

range("a" & i & ":e" & i).select '然後選擇ai:ei

selection.delete shift:=xlup '下方單元格上移的方式刪除該行,這樣刪除不會影響到f列的資料

end if

next

end sub

13樓:

假設你要查詢的空白單元格在b列

sub my()

dim i as long

for i = 1 to [a65536].end(xlup).row

if cells(i, 2) = "" then '這裡的2就是你的列數,可以自己替換

rows(i & ":" & i).delete shift:=xlup

end if

next

end sub

14樓:平陽虎

sub 刪除行()

for i = [b65536].end(3).row to 2 step -1

if cells(i, 2) = "" then rows(i & ":" & i).delete shift:=xlup

next

end sub

15樓:匿名使用者

sub delblank()

on error resume next

columns("b:b").specialcells(xlcelltypeblanks).entirerow.delete

end sub

16樓:匿名使用者

sub 空值則刪除整行()

with activesheet

for i = .[a65536].end(3).row to 1 step -1 '這裡的1是你的表頭行數

if .cells(i, 2) = "" then .rows(i).delete '這裡的2就是你的列數,可以自己替換

next

end with

end sub

ecel中如何用vba向單元格賦值

sheet1.cells 2,1 value 祝你快樂 也可以 worksheets sheet1 range b1 value 祝你快樂 其中sheet是你所在的 sheet1是第一張表 activecell.formular1c1 祝你快樂!你看是這樣嗎? 玩手機的張先生 sub sss dim...

EXCEL單元格上箭頭如何刪除,如何取消excel單元格的箭頭

真的不能點箭頭嗎?你有沒試過另外的excel 軟體?我試了下,邊框貌似不能設為這樣的,要不行,我估計可能有 設定的。 你這個不好判斷,除非你把檔案發給我才能判斷。發我郵箱905854449 qq.com 如何取消excel單元格的箭頭 選中左上角有三角箭頭的單元格,會看到一個黃色標識的提示符,點開,...

在EXCEl中,用VBA實現單元格顏色改變

dim i r whit sheets 表名稱 r range a65536 end xlup rowfor i 1 to r if cells i,1 value 20 then.cells i,1 font.colorindex 4eed if if cells i,1 value 19 and...