Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

if else statement

$
0
0
hi
im using thses line of code to pull stuff of an excel sheet
Code:

     
 oRng = oWSSheet2.Cells.Find("Class B", , _
Excel.XlFindLookIn.xlValues, Excel.XlLookAt.xlPart, _
Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlNext, False)
        ' MsgBox("Value '" & app oRng.Value & "' found at '" & oRng.Address)
            Me.classb = oRng.Offset(0, 42).Value
            oRng = Nothing

but sometime some spreadsheets wont have the word class b in it but i get an error if it doesnt. i want to put in an if statement so if its null to go to next piece of code.

how can this be done in vb

if i try this
if orng is not null then
Me.classb = oRng.Offset(0, 42).Value
else
....
but that's not quite right

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>