Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Delete code
Hi,
Could some give me a code please to delete the entrie row if any cell in col C of that row starting from c10 going to the last cell down = ""? Thanks LiAD |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Delete code
This should work for you. Just place this code into a standard module and
adjust the name on the worksheet you want to use. Option Explicit Sub DeleteRows() Dim lngLastRow As Long Dim i As Long With Sheets("Sheet1") lngLastRow = .Cells(Rows.Count, "C").End(xlUp).Row For i = lngLastRow To 10 Step -1 If Cells(i, "C").Value = "" Then Rows(i).EntireRow.Delete Shift:=xlUp End If Next i End With End Sub Hope this helps! If so, click "YES" below. -- Cheers, Ryan "LiAD" wrote: Hi, Could some give me a code please to delete the entrie row if any cell in col C of that row starting from c10 going to the last cell down = ""? Thanks LiAD |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Delete code
Correction,
Option Explicit Sub DeleteRows() Dim lngLastRow As Long Dim i As Long With Sheets("Sheet1") lngLastRow = .Cells(Rows.Count, "C").End(xlUp).Row For i = lngLastRow To 10 Step -1 If .Cells(i, "C").Value = "" Then .Rows(i).EntireRow.Delete Shift:=xlUp End If Next i End With End Sub -- Cheers, Ryan "Ryan H" wrote: This should work for you. Just place this code into a standard module and adjust the name on the worksheet you want to use. Option Explicit Sub DeleteRows() Dim lngLastRow As Long Dim i As Long With Sheets("Sheet1") lngLastRow = .Cells(Rows.Count, "C").End(xlUp).Row For i = lngLastRow To 10 Step -1 If Cells(i, "C").Value = "" Then Rows(i).EntireRow.Delete Shift:=xlUp End If Next i End With End Sub Hope this helps! If so, click "YES" below. -- Cheers, Ryan "LiAD" wrote: Hi, Could some give me a code please to delete the entrie row if any cell in col C of that row starting from c10 going to the last cell down = ""? Thanks LiAD |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Delete code
Sub delSome() Dim lr As Long, rng As Range lr = ActiveSheet.Cells(Rows.Count, 3).End(xlUp).Row Set rng = ActiveSheet.Range("C10:C" & lr) For Each c In rng If c.Value = "" Then c.EntireRow.Delete End If Next End Sub "LiAD" wrote in message ... Hi, Could some give me a code please to delete the entrie row if any cell in col C of that row starting from c10 going to the last cell down = ""? Thanks LiAD |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Delete code
Sorry, delete should go from bottom up.
Sub delSome() Dim lr As Long lr = ActiveSheet.Cells(Rows.Count, 3).End(xlUp).Row 'Set rng = ActiveSheet.Range("C10:C" & lr) For i = lr To 10 Step - 1 If Cells(i, 3) = "" Then Cells(i, 3).EntireRow.Delete End If Next End Sub "JLGWhiz" wrote in message ... Sub delSome() Dim lr As Long, rng As Range lr = ActiveSheet.Cells(Rows.Count, 3).End(xlUp).Row Set rng = ActiveSheet.Range("C10:C" & lr) For Each c In rng If c.Value = "" Then c.EntireRow.Delete End If Next End Sub "LiAD" wrote in message ... Hi, Could some give me a code please to delete the entrie row if any cell in col C of that row starting from c10 going to the last cell down = ""? Thanks LiAD |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Delete code
Thanks
"Ryan H" wrote: Correction, Option Explicit Sub DeleteRows() Dim lngLastRow As Long Dim i As Long With Sheets("Sheet1") lngLastRow = .Cells(Rows.Count, "C").End(xlUp).Row For i = lngLastRow To 10 Step -1 If .Cells(i, "C").Value = "" Then .Rows(i).EntireRow.Delete Shift:=xlUp End If Next i End With End Sub -- Cheers, Ryan "Ryan H" wrote: This should work for you. Just place this code into a standard module and adjust the name on the worksheet you want to use. Option Explicit Sub DeleteRows() Dim lngLastRow As Long Dim i As Long With Sheets("Sheet1") lngLastRow = .Cells(Rows.Count, "C").End(xlUp).Row For i = lngLastRow To 10 Step -1 If Cells(i, "C").Value = "" Then Rows(i).EntireRow.Delete Shift:=xlUp End If Next i End With End Sub Hope this helps! If so, click "YES" below. -- Cheers, Ryan "LiAD" wrote: Hi, Could some give me a code please to delete the entrie row if any cell in col C of that row starting from c10 going to the last cell down = ""? Thanks LiAD |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Delete code
Assuming your cells in Column C have data in them so that your ="" condition
means an empty cell, and not formulas that evaluate to "", then give this "non looping" macro a try... Sub DeleteEmptyCellsColumnC() On Error Resume Next Range("C10:C" & Cells(Rows.Count, "C").End(xlUp).Row). _ SpecialCells(xlCellTypeBlanks).EntireRow.Delete End Sub -- Rick (MVP - Excel) "LiAD" wrote in message ... Hi, Could some give me a code please to delete the entrie row if any cell in col C of that row starting from c10 going to the last cell down = ""? Thanks LiAD |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Delete code after use | Excel Programming | |||
How to Delete VBS code via VBA | Excel Programming | |||
Code to delete a Line in a another code | Excel Programming | |||
VBA code delete code but ask for password and unlock VBA protection | Excel Programming | |||
VBA code to delete VBA code in another Workbook | Excel Programming |