#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Empty row

Hi! I have a part of a code that reads names from a long list. The length of
the list changes from time to time but the boundaries are given by the range
"position". Now I read the entire range but I want it to only read the rows
the are non empty. when the first empty rows comes then i want it to stop.
Thus the problem is the the row: Nop = rngPositions.Rows.Count
or somewhere related to that but I dont know how to get it right. pls help!


Dim rngPositions As Range
Set rngPositions =
Application.ThisWorkbook.Sheets("Data").Range("pos ition")
Dim Nop As Long
Nop = rngPositions.Rows.Count
ReDim Positions(1 To Nop) As Double
Dim i As Integer
For i = 1 To Nop
Positions(i) = rngPositions.Cells(i, 1)
Next i
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Empty row

Hi Arne

Sub pos()

Dim rngPositions As Range
Dim i As Long
Dim Nop As Long
Dim Positions

Set rngPositions = Sheets("Data").Range("position")
Nop = rngPositions(1).End(xlDown).Row - rngPositions(1).Row + 1
Set rngPositions = rngPositions.Resize(Nop)

ReDim Positions(1 To Nop) As Double
Positions = rngPositions.Value


'for matters of control (delete it if you want)
Debug.Print rngPositions.Address

For i = LBound(Positions, 1) To UBound(Positions, 1)
Debug.Print Positions(i, 1)
Next
End Sub


--
Wigi
http://www.wimgielis.be = Excel/VBA, soccer and music
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Empty row

Certainly not essential, but
Debug.Print Positions(i, 1)

should be

Debug.Print Positions(i)

--
Regards,
Tom Ogilvy



"Wigi" wrote:

Hi Arne

Sub pos()

Dim rngPositions As Range
Dim i As Long
Dim Nop As Long
Dim Positions

Set rngPositions = Sheets("Data").Range("position")
Nop = rngPositions(1).End(xlDown).Row - rngPositions(1).Row + 1
Set rngPositions = rngPositions.Resize(Nop)

ReDim Positions(1 To Nop) As Double
Positions = rngPositions.Value


'for matters of control (delete it if you want)
Debug.Print rngPositions.Address

For i = LBound(Positions, 1) To UBound(Positions, 1)
Debug.Print Positions(i, 1)
Next
End Sub


--
Wigi
http://www.wimgielis.be = Excel/VBA, soccer and music

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Empty row

OK. Taken note of.

--
Wigi
http://www.wimgielis.be = Excel/VBA, soccer and music


"Tom Ogilvy" wrote:

Certainly not essential, but
Debug.Print Positions(i, 1)

should be

Debug.Print Positions(i)

--
Regards,
Tom Ogilvy

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
Delete Rows with Empty Cells with empty column 1 Scott Excel Programming 5 October 2nd 06 11:57 PM
why a reference to an empty cell is not considered empty Nicoscot Excel Discussion (Misc queries) 10 March 10th 06 05:36 AM
Finding next empty empty cell in a range of columns UncleBun Excel Programming 1 January 13th 06 11:22 PM
Excel - Autom. Filter "Empty / Non Empty cells" should come first Rom Excel Discussion (Misc queries) 0 August 10th 05 04:32 PM
Can blank cells created using empty Double-Quotes not be empty?? JohnI in Brisbane Excel Programming 6 September 7th 03 11:22 PM


All times are GMT +1. The time now is 10:22 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"