Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hope someone can help with some code. I've read the other examples and I'm
not sure if what I'm trying to do can be accomplished by the others. A cell in column A has data in it (doesn't matter what the data is). If the cells in Columns B thru AB are blank, I want to delete the row. Chuck |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
are you trying to delete the entire row column a thru ab? is it something you
want to do automatically? otherwise you can clikc on the row to the left, right click and go to delete row... -- --Chip Smith-- MVP Wannabe :) "Chuck Neal" wrote: Hope someone can help with some code. I've read the other examples and I'm not sure if what I'm trying to do can be accomplished by the others. A cell in column A has data in it (doesn't matter what the data is). If the cells in Columns B thru AB are blank, I want to delete the row. Chuck |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Yes, I want to delete the entire row A thru IV. The reason I said AB as the
end column is because I do not have data past there. I want a code because I'm trying to incorporate it into an existing macro series I'm running. I'm trying to automate this process as much as possible to avoid human error. "Chip Smith" wrote: are you trying to delete the entire row column a thru ab? is it something you want to do automatically? otherwise you can clikc on the row to the left, right click and go to delete row... -- --Chip Smith-- MVP Wannabe :) "Chuck Neal" wrote: Hope someone can help with some code. I've read the other examples and I'm not sure if what I'm trying to do can be accomplished by the others. A cell in column A has data in it (doesn't matter what the data is). If the cells in Columns B thru AB are blank, I want to delete the row. Chuck |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Sure, but do you really need code?
In say col AC use a formula such as =COUNTA(B2:AB2) and copy down. Filter on col AC for the value 0, then select what you can see, do Edit / Go to / Special / Visible cells only, and then do Edit / Delete / Entire row. Take off the filter and you are done. -- Regards Ken....................... Microsoft MVP - Excel Sys Spec - Win XP Pro / XL 97/00/02/03 ------------------------------*------------------------------*---------------- It's easier to beg forgiveness than ask permission :-) ------------------------------*------------------------------*---------------- "Chuck Neal" wrote in message ... Hope someone can help with some code. I've read the other examples and I'm not sure if what I'm trying to do can be accomplished by the others. A cell in column A has data in it (doesn't matter what the data is). If the cells in Columns B thru AB are blank, I want to delete the row. Chuck |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi Chuck,
I found the following code on Chip Pearson's page and modifed it slightly. See if this works for you. It counts the number of entries in the B to AB range and deletes the row if the count is 0. ------------------------ Option Explicit Public Sub DeleteBlankRows() Dim R As Long Dim C As Range Dim Rng As Range On Error GoTo EndMacro Application.ScreenUpdating = False Application.Calculation = xlCalculationManual If Selection.Rows.Count 1 Then Set Rng = Selection Else Set Rng = ActiveSheet.UsedRange.Rows End If For R = Rng.Rows.Count To 1 Step -1 If Application.WorksheetFunction.CountA(Rng.Range("B" & R & ":AB" & R)) _ = 0 Then Rng.Rows(R).EntireRow.Delete End If Next R EndMacro: Application.ScreenUpdating = True Application.Calculation = xlCalculationAutomatic End Sub -- Ken Hudson "Chuck Neal" wrote: Hope someone can help with some code. I've read the other examples and I'm not sure if what I'm trying to do can be accomplished by the others. A cell in column A has data in it (doesn't matter what the data is). If the cells in Columns B thru AB are blank, I want to delete the row. Chuck |
#6
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I thought for sure that would work because it makes sense, but it didn't.
Thanks though! "Ken Hudson" wrote: Hi Chuck, I found the following code on Chip Pearson's page and modifed it slightly. See if this works for you. It counts the number of entries in the B to AB range and deletes the row if the count is 0. ------------------------ Option Explicit Public Sub DeleteBlankRows() Dim R As Long Dim C As Range Dim Rng As Range On Error GoTo EndMacro Application.ScreenUpdating = False Application.Calculation = xlCalculationManual If Selection.Rows.Count 1 Then Set Rng = Selection Else Set Rng = ActiveSheet.UsedRange.Rows End If For R = Rng.Rows.Count To 1 Step -1 If Application.WorksheetFunction.CountA(Rng.Range("B" & R & ":AB" & R)) _ = 0 Then Rng.Rows(R).EntireRow.Delete End If Next R EndMacro: Application.ScreenUpdating = True Application.Calculation = xlCalculationAutomatic End Sub -- Ken Hudson "Chuck Neal" wrote: Hope someone can help with some code. I've read the other examples and I'm not sure if what I'm trying to do can be accomplished by the others. A cell in column A has data in it (doesn't matter what the data is). If the cells in Columns B thru AB are blank, I want to delete the row. Chuck |
#7
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
The code works in my test worksheet. Are you certain that B thru AB are truly
empty? As a test highlight a range from B to AB that you think is empty and then go to Edit Clear All. If you run the macro, does that row get deleted? -- Ken Hudson "Chuck Neal" wrote: I thought for sure that would work because it makes sense, but it didn't. Thanks though! "Ken Hudson" wrote: Hi Chuck, I found the following code on Chip Pearson's page and modifed it slightly. See if this works for you. It counts the number of entries in the B to AB range and deletes the row if the count is 0. ------------------------ Option Explicit Public Sub DeleteBlankRows() Dim R As Long Dim C As Range Dim Rng As Range On Error GoTo EndMacro Application.ScreenUpdating = False Application.Calculation = xlCalculationManual If Selection.Rows.Count 1 Then Set Rng = Selection Else Set Rng = ActiveSheet.UsedRange.Rows End If For R = Rng.Rows.Count To 1 Step -1 If Application.WorksheetFunction.CountA(Rng.Range("B" & R & ":AB" & R)) _ = 0 Then Rng.Rows(R).EntireRow.Delete End If Next R EndMacro: Application.ScreenUpdating = True Application.Calculation = xlCalculationAutomatic End Sub -- Ken Hudson "Chuck Neal" wrote: Hope someone can help with some code. I've read the other examples and I'm not sure if what I'm trying to do can be accomplished by the others. A cell in column A has data in it (doesn't matter what the data is). If the cells in Columns B thru AB are blank, I want to delete the row. Chuck |
#8
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I tried again, but ran your code in a different location in my master macro
and it worked great. It actually deleted other rows that I was deleting with a different macro, so even better! Thanks again!!! "Ken Hudson" wrote: The code works in my test worksheet. Are you certain that B thru AB are truly empty? As a test highlight a range from B to AB that you think is empty and then go to Edit Clear All. If you run the macro, does that row get deleted? -- Ken Hudson "Chuck Neal" wrote: I thought for sure that would work because it makes sense, but it didn't. Thanks though! "Ken Hudson" wrote: Hi Chuck, I found the following code on Chip Pearson's page and modifed it slightly. See if this works for you. It counts the number of entries in the B to AB range and deletes the row if the count is 0. ------------------------ Option Explicit Public Sub DeleteBlankRows() Dim R As Long Dim C As Range Dim Rng As Range On Error GoTo EndMacro Application.ScreenUpdating = False Application.Calculation = xlCalculationManual If Selection.Rows.Count 1 Then Set Rng = Selection Else Set Rng = ActiveSheet.UsedRange.Rows End If For R = Rng.Rows.Count To 1 Step -1 If Application.WorksheetFunction.CountA(Rng.Range("B" & R & ":AB" & R)) _ = 0 Then Rng.Rows(R).EntireRow.Delete End If Next R EndMacro: Application.ScreenUpdating = True Application.Calculation = xlCalculationAutomatic End Sub -- Ken Hudson "Chuck Neal" wrote: Hope someone can help with some code. I've read the other examples and I'm not sure if what I'm trying to do can be accomplished by the others. A cell in column A has data in it (doesn't matter what the data is). If the cells in Columns B thru AB are blank, I want to delete the row. Chuck |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Confirm before deleting a worksheet? | Excel Discussion (Misc queries) | |||
deleting values in a worksheet without deleting the formulas | Excel Worksheet Functions | |||
how prevent formula in cell from deleting when deleting value???? | New Users to Excel | |||
Deleting #N/A from cells... | Excel Discussion (Misc queries) | |||
delete values in several cells without deleting the formulas | Excel Discussion (Misc queries) |