Access value in cell

  • Thread starter Thread starter BI-Bill
  • Start date Start date
B

BI-Bill

Guest
I've taken some older VBS code and moved it into VB.net app.

A lot of the code works with some changes. I've tried to make several sub routines based on what the users need.

Here is the beginning of some of my issues...

The new VB app is supposed to read an excel file and then based on the value in a certain cell, do something.

My loop works just fine...meaning I can see the code loops through all the data in the range.

What isn't working is seeing the actual data in the identified cell.

I have:

iLastRow = sheet.Cells(sheet.Rows.Count, 3).End(xlUp).Row
For iRow = iLastRow To 2 Step -1

Dim val As String = sheet.Range("D" & iRow).ToString 'returns system object
If val = "SomeSpecificValue" Then
'my specific value never gets found and I never delete the row...
sheet.Range("D" & iRow).EntireRow.Delete
Else
'Do some other stuff
End If
Next

I've changed my type several times, I've looked for TEXT & Value instead of ToString....all to no avail.

I feel like I'm close, but something is off.. any pointers or suggestions would be most welcome. Thanks, B

Continue reading...
 
Back
Top