View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Zilla[_4_] Zilla[_4_] is offline
external usenet poster
 
Posts: 17
Default How come VBA if clause fails?

I have the following subroutine. Why can't I see the passed-in Range's
Cells(x,y).Value?

Sub getDataInfo2(sRange As Range)
Const maxr = 15
Const defSize = 100
Dim row As Integer
Dim col As Integer
Dim i As Integer
Dim size As Integer
Dim buffer(defSize)

' Get data from source range
row = sRange.row
col = sRange.Column
size = 0
For i = 0 To maxr
If sRange.Cells(row, col).Value < "" Then
' This if() NEVER passes - ???????????????????????
buffer(size) = sRange.Cells(row, col).Value
size = size + 1
End If
col = col + 1
Next i
End Sub


Sub test()
Dim baseBook As Workbook
Dim currSheet As Worksheet
Dim sRange as Range

set baseBook = ThisWorkbook
set currSheet = baseBook.Sheets(2)
currSheet.Activate
set sRange = currSheet.Range("A1:J1")
' I CAN SEE CELL VALUES IN THE RANGE HERE
Call getDataInfo2(sRange)
End Sub

Any clues?