LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default range variable across sheets

Hi,

The routine below makes sure that there are exactly 2 blanc rows between
square blocks of data.
It iterates over all blocks that are currently seperated by 1 or more
blanc rows and either inserts or deletes blanc rows accordingly.
Unfortunately it only works on the first sheet.
Apparently this statement :

Set celbottom = .Cells(65536, 1).End(xlUp)

continues to refer to the first sheet, although it is inside a for each
loop that iterates over all sheets.


Thanks for any help


Ward




Public Sub rowrijen()
Dim celbottom As Range, celtop As Range, bereik As Range
Dim ws As Worksheet
Dim adres As String

For Each ws In Worksheets
With ws
If .Name < "synthese" Then
Set celbottom = .Cells(65536, 1).End(xlUp)
Set celbottom = celbottom.End(xlUp)
Do Until celbottom.Row = 1
Set celbottom = celbottom.Offset(-1, 0)
Set celtop = celbottom.End(xlUp)
Set celtop = celtop.Offset(1, 0)
adres = celtop.Address
Set bereik = Range(celbottom, celtop)
If bereik.Rows.Count = 2 Then
Do While bereik.Rows.Count 2
.Range(adres).EntireRow.Delete
Loop
Else
.Range(adres).EntireRow.Insert
End If
Set celbottom = Range(adres).End(xlUp)
Set celbottom = celbottom.End(xlUp)
Loop

End If
End With
Next
End Sub
 
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
add new sheets in a workbook with new sheets being a variable [email protected] Excel Discussion (Misc queries) 1 April 11th 06 08:38 PM
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Excel Worksheet Functions 6 March 29th 06 12:43 PM
Use of variable to identify range of sheets in a workbook rhs414 Excel Discussion (Misc queries) 1 June 20th 05 01:42 PM
setting a range variable equal to the value of a string variable Pilgrim Excel Programming 2 July 1st 04 11:32 PM
Problem trying to us a range variable as an array variable TBA[_2_] Excel Programming 4 September 27th 03 02:56 PM


All times are GMT +1. The time now is 12:26 PM.

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

About Us

"It's about Microsoft Excel"