Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > Deleting Rows with empty cells in a specific column


Reply
 
Thread Tools Display Modes
  #1  
Old 06-14-2009, 12:32 PM
Frankie80 Frankie80 is offline
Newcomer
 
Join Date: Jun 2009
Posts: 3
Default no luck


Edit by Moderator: Re http://www.xtremevbtalk.com/showthread.php?t=130452


I tried to use this code in an excel 2007 macro but it didn't like the "set" in the third line and gave me an error message " invalid outside procedure "

I would certainly appreciate any help for the clueless rookie

Last edited by Colin Legg; 06-14-2009 at 04:01 PM.
Reply With Quote
  #2  
Old 06-14-2009, 02:28 PM
HaHoBe's Avatar
HaHoBe HaHoBe is offline
Centurion
 
Join Date: Sep 2005
Posts: 176
Default

Hi, Frankie80,

did you copy all the code and do you have a worksheet called Sheet1 in your workbook?

Ciao,
Holger
Attached Files
File Type: zip XTreme130452.zip (13.5 KB, 1 views)
Reply With Quote
  #3  
Old 06-14-2009, 03:08 PM
Frankie80 Frankie80 is offline
Newcomer
 
Join Date: Jun 2009
Posts: 3
Default

Thanks Holger,

I used all the code in post #4
I changed the name to "All Days" which is the name of the sheet I'm trying to automate
I also changed 6 to 9 as my column I'm trying to filter on is the "i" column
Still no luck same error message

this is what I tried to run


Dim CheckRange As Range, DeleteRange As Range

Set CheckRange = Worksheets("All Days").Columns(9)
CheckRange.AutoFilter Field:=1, Criteria1:="="

Set DeleteRange = CheckRange.SpecialCells(xlCellTypeVisible).EntireRow
DeleteRange.Delete
Reply With Quote
  #4  
Old 06-14-2009, 09:53 PM
HaHoBe's Avatar
HaHoBe HaHoBe is offline
Centurion
 
Join Date: Sep 2005
Posts: 176
Default

Hi, Frankie80,

sorry, I donīt see the reason for the error (works fine in my example) - what about the use of a modified code:

Code:
Sub DeleteEmptyCells2()

Const cstrSheet As String = "All Days"
Const clngColumn As Long = "9"

On Error Resume Next
Worksheets(cstrSheet).UsedRange.Columns(clngColumn).SpecialCells(xlCellTypeBlanks).EntireRow.Delete

If Err <> 0 Then
  MsgBox "Error: " & Err.Number & vbCrLf & "Desprition: " & Err.Description
End If

End Sub
If the error still shows up could you please show all the code used in the module and indicate where it is located as maybe the error occurs from putting the code segment outside of a procedure or function?

Ciao,
Holger
Reply With Quote
  #5  
Old 06-15-2009, 10:53 PM
Frankie80 Frankie80 is offline
Newcomer
 
Join Date: Jun 2009
Posts: 3
Default

Holger - Thanks again

Well clueless me has just been opening the editor and pasting that cut with nothing before or after it. Might be my problem. Tomorrow I hope to get time to work on the project. I appreciate your help for sure and wish you a good day

Paul
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->