Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Addressing Question in Excel Macro

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Addressing Question in Excel Macro

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

http://www.vonixx.com



"Bob" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Array addressing question... I think John Bennett[_2_] Excel Worksheet Functions 1 February 15th 10 11:04 AM
How to record macro with relative addressing in Excel 2000 Rond Excel Discussion (Misc queries) 6 August 13th 09 02:47 PM
Addressing the Excel file in which the macro is present. neeraja Excel Programming 1 October 20th 03 10:02 AM
Auto Email via xlDialogSendMail addressing question Tom Ogilvy Excel Programming 0 September 17th 03 05:28 PM
Auto Email via xlDialogSendMail addressing question Jake Marx Excel Programming 0 September 17th 03 05:26 PM


All times are GMT +1. The time now is 10:09 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"