467,076 Members | 981 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,076 developers. It's quick & easy.

Delete an Entire Row in .vbs

I'm hoping this is the right sub-forum to post this question, my apologies if it's not.


The problem I'm having is that I can't get a blank row to be deleted. Below is a section of code where the Selection.EntireRow.Delete should occur.

'-- Loop through to make sure only MS Patches are there. Delete Empty rows
For row = 2 To allRows
allString = xlSReport.Cells(row,2)
If (allString = "") Then
allString.EntireRow.Delete
End If
'Do Nothing
Next
xlSReport.columns(1).Autofit()
xlSReport.columns(2).Autofit()
xlSReport.columns(4).Autofit()
xlSReport.columns(5).Autofit()
Nov 3 '08 #1
  • viewed: 2873
Share:
1 Reply
Expert Mod 2GB
What type is your variable AllString? It looks like it should be a Range object, but if it is you are not using the object Set keyword to set it to the range defined by Cells(row, 2) in your FOR loop - which would normally cause a compiler error.

If it is a string, then you cannot use that string as a range object to delete the row inside your IF - and again, trying to do so should throw up a compiler error.

I guess you might have used an untyped variant for AllString - but if you have this will not work either. The EntireRow.Delete method is a property of a range object, and this is what you must supply if you expect it to work.

One way or the other you seem to be using an incorrect type here.

-Stewart
Nov 6 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Pelle | last post: by
14 posts views Thread by Timothy Madden | last post: by
9 posts views Thread by Robert Schneider | last post: by
4 posts views Thread by Susan Bricker | last post: by
6 posts views Thread by Karl Richards | last post: by
9 posts views Thread by Juergen Huber | last post: by
15 posts views Thread by LuB | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.