PDA

View Full Version : Vba process entire row delete



imrankhan
09-12-2019, 06:16 AM
check wheather column C has data if yes then do nothing if no then delete that entire row by vba
file name sonu.csv file is located in C:\Users\soniya\Desktop
i will put a macro in different file and both files are located in same place
save it after the process completed and close it

imrankhan
09-14-2019, 09:29 AM
https://www.ozgrid.com/forum/forum/help-forums/excel-vba-macros/1223141-vba-process-entire-row-delete

Kenneth Hobs
09-14-2019, 09:36 AM
You will have to be more clear. If no data in column F, delete all rows? That means clear the whole worksheet.

imrankhan
09-14-2019, 11:12 AM
If cells in column F has no data then delete that entire row only
Example
If F15 is blank then delete that entire row only and look for next if found then delete and so on.....
Thnx Kenneth Hobs Sir for showing interest in this post
If u have more doubts then plz ask

Aussiebear
09-14-2019, 11:15 AM
@imrankhan. Your request to have this thread deleted is going to be declined. Just because it has been noted that you have posted the issue elsewhere and failed to notify either forum of “cross posting” does not justify removing the thread.

Kenneth Hobs
09-14-2019, 11:41 AM
Sub DelFBlanks()
On Error Resume Next
Columns("F").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub

imrankhan
09-14-2019, 08:08 PM
Sub Mysub()
Dim wbk1 As Workbook
Dim wsh1 As Worksheet
Application.ScreenUpdating = False
Set wbk1 = Workbooks.Open(ThisWorkbook.Path & "\123..csv")
Set wsh1 = wbk1.Worksheets(1)
With wsh1
On Error Resume Next
Columns("F").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End If
Application.DisplayAlerts = False
wkb1.Close SaveChanges:=True
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub


Ur code is working Sir but as i said i wil put the macro in different file so i made this code and this code contains error so plz have a look Sir and help

Kenneth Hobs
09-14-2019, 08:40 PM
How does that run?


wsh1.Columns("F").SpecialCells(xlCellTypeBlanks).EntireRow.Delete

imrankhan
09-14-2019, 08:54 PM
Sub Mysub() Dim wbk1 As Workbook
Dim wsh1 As Worksheet

Application.ScreenUpdating = False

Set wbk1 = Workbooks.Open(ThisWorkbook.Path & "\123..csv")
Set wsh1 = wbk1.Worksheets(1)

With wsh1
On Error Resume Next
wsh1.Columns("F").SpecialCells(xlCellTypeBlanks).EntireRow.Delete

End If








Application.DisplayAlerts = False
wbk1.Close SaveChanges:=True
Application.DisplayAlerts = True

Application.ScreenUpdating = True

End Sub

after changing the same then also code is not working Sir

Kenneth Hobs
09-14-2019, 09:07 PM
It will not run because it will not compile. Even a Run will usually tell you what and where the problem is as does Debug menu's Compile. Try to use Compile before a Run.

Why use With when you added the sheet object? It serves no purpose. Either delete it or add End With. With is best used when you have multiple object calls.

imrankhan
09-14-2019, 09:11 PM
Thnx Alot Kenneth Hobs Sir for giving ur Precious Time and Great Support to this Post
Have a Great Day Sir

imrankhan
09-15-2019, 01:03 AM
Sorry Aussiebear Thnx for not deleting this post
Thnx for the help Sir