View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Sheeloo[_3_] Sheeloo[_3_] is offline
external usenet poster
 
Posts: 1,805
Default getting Cell2.value=empty when their are values in the column

Code is Ok...

I tested the following with A19 having the string "Project assignments"

I got 18 as the value of br

Sub test()
Dim br As Long
br = 0
Sheets("SAPTasks").Select
Cells.Select
Columns("a:a").Select
Dim Cell2 As Range
For Each Cell2 In Selection
If Cell2.Value = "Project assignments" Then
Exit For
End If
br = br + 1
Next Cell2
MsgBox br
End Sub
--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"Bud" wrote:

Hello

When I run through F8 in the following code I am getting Cell2.value is
empty when it reads down through columnA. This is true for every row except
for the first row. It shows me the value of what is in A1. After that I get
EMPTY.

The worksheet that I am reading has 3 reports in it and is standard. I only
want to process what comes out of the 1st report in that 1 worksheet. I don't
care about the other 2 reports in that 1 worksheet. So I am trying to count
the number of rows before I reach the 2nd report. the 2nd report starts with
"Project assignments".

What is wrong with this code?
Dim br As Long
br = 0
Sheets("SAPTasks").Select
Cells.Select
Columns("a:a").Select
Dim Cell2 As Range

For Each Cell2 In Selection
If Cell2.Value = "Project assignments" Then
Exit For
End If
br = br + 1
Next Cell2