Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Addressing Question in Excel Macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bob - 24 Jan 2006 04:31 GMT
I'm reducing a 6000 row data set by four fold.  I wanted to use the following
macro to delete every three rows, but the String function doesn't seem to
work in a macro to generate a valid row range.  Suggestions?

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 1/22/2006 by Bob
'
   Row_start = 12
   Row_end = Row_start + 2
   Do While Row_start < 1600    
       RS = Str(Row_start)
       RE = Str(Row_end)
       Address = RS & ":" & RE
       Rows(Address).Select
       Selection.Delete
       Row_start = Row_start + 1
       Row_end = Row_end + 1        
   Loop    

End Sub
Edwin Tam - 24 Jan 2006 06:00 GMT
I assume your list start at cell A1.
There are quite a number of errors in your original macro. Therefore, I
decided to rewrite it for you. Try the one below:

Sub Macro1()
Dim tmp As Single
Dim tmp2 As Integer
With ActiveSheet.Range("A1").CurrentRegion
   tmp2 = .Rows.Count Mod 3
   For tmp = .Rows.Count - tmp2 To 3 Step -3
       .Rows(tmp).EntireRow.Delete
   Next
End With
End Sub

Regards,
Edwin Tam
edwintam@vonixx.com
http://www.vonixx.com

> I'm reducing a 6000 row data set by four fold.  I wanted to use the following
> macro to delete every three rows, but the String function doesn't seem to
[quoted text clipped - 18 lines]
>
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.