Excel VBA to Delete Row or Column in Excel Table

Excel VBA to Delete Row or Column in Excel Table

Chester Tugwell

5 лет назад

29,400 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Emmanuel Alvarado
Emmanuel Alvarado - 05.04.2023 19:34

HI Chester
if i select multiple rows how i can delete

Ответить
Chairul Umam
Chairul Umam - 16.06.2021 11:17

how to change row 2 with selected, hhmmm for example i klik no 5 then delete the number 5

Ответить
Marc Q
Marc Q - 06.01.2021 09:23

Great information, however a bit incomplete.
I don't know how many rows I have in my table and I want to delete all rows but the header. How do I do that?
Thanks

Ответить
sam joseph
sam joseph - 09.12.2020 20:21

Hello,
Very helpful video. I have one question, how to delete all the rows. Thanks

Ответить
Stu Gryffin
Stu Gryffin - 16.10.2020 04:54

Hi Chester. Thanks for this video. Is there any way to define the column by its header name instead of it's row number? The structure of my table is not fully stable and I would like to prevent my script from breaking after the insertion/removal of other columns.

Ответить
Abdulhamid Alhaddadi
Abdulhamid Alhaddadi - 24.06.2020 15:59

Thank you sir, I have 2 questions if you don't mind
1. How can I use this code in multiple sheets with different names.
2. How can I apply this code to multiple sheets.
Thank you again.

Ответить
UAB Agrimera
UAB Agrimera - 06.08.2019 20:00

Hello SIr,


How to - to remove duplicates within a row by Excel VBA ?

Example
597 2733 2710 2710 2687 2687 2687 2687
597 2710 2688 2688 2687 2687 2687 2687

597 2688 2713 2713 2734 2734 2734 2734


Need this one for final code:
597 2733 2710 2687
597 2710 2688 2687
597 2688 2713 2734


We found a code with only mark, but not delete.
Can you help for us ?


Sub DuplicateValuesFromRow()
'Declare All Variables.
Dim myCell As Range
Dim myRow As Integer
Dim myRange As Range
Dim myCol As Integer
Dim i As Integer
'Count Number of Rows and Columns
myRow = Range(Cells(1, 1), Cells(1, 1).End(xlDown)).Count
myCol = Range(Cells(1, 1), Cells(1, 1).End(xlToRight)).Count
'Loop Each Row To Check Duplicate Values and Highlight cells.
For i = 2 To myRow
Set myRange = Range(Cells(i, 2), Cells(i, myCol))
For Each myCell In myRange
If WorksheetFunction.CountIf(myRange, myCell.Value) > 1 Then
myCell.Interior.ColorIndex = 3
End If
Next
Next
End Sub

Ответить