VBA code need to account for empty rows

The code looks at three sheets and runs code.
But there is a possibility that there is nothing on one of the three rows.
This resulted in an error - can I add a handler?

Sub GetSCS(strSheet As String, varCol As Variant)

Error on                 intLowWt = varDataS(lngRowS, 2)

in this circumstance, I had no data in sheet Intl
What-if-scenario-v4.3.xlsm
Euro5Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NorieVBA ExpertCommented:
What's the error?

How can we recreate it? ie which sub should be run or button press
0
Euro5Author Commented:
the sub is Sub GetSCSDriver() which calls the
Sub GetSCS(strSheet As String, varCol As Variant)

You could use the button, but probably more expedient just to run the
Sub GetSCSDriver

THANKS!!
0
Martin LissOlder than dirtCommented:
Add line 23 (I didn't show all the sub)..
Sub GetSCS(strSheet As String, varCol As Variant)
Dim lngLastRowS As Long
Dim lngLastRowD As Long
Dim lngRowS As Long
Dim lngRowD As Long
Dim lngE As Long
Dim strParts() As String
Dim intLowWt As Integer
Dim intHighWt As Integer
Dim varDataS As Variant
Dim varDataD As Variant
Dim MyVar As String
Dim rgBD As Variant
Dim rgBM As Range
Application.Calculation = xlCalculationManual
lngLastRowD = Sheets("Detail").UsedRange.Rows.Count

lngLastRowS = Sheets(strSheet).Range("A80000").End(xlUp).Row
' Note that these are set up to be the VALUES in the sheet rather than
' this which would refer to the sheet itself
'    Set varDataS = Sheets("Summary").Range("A3:E" & lngLastRowS)
varDataS = Sheets(strSheet).Range("A3:AQ" & lngLastRowS).Value
If UBound(varDataS) = 3 Then Exit Sub

varDataD = Sheets("Detail").Range("A2:BI" & lngLastRowD).Value

With Sheets("Detail")
    Set rgBM = Range(.Cells(2, varCol), .Cells(.Rows.Count, varCol).End(xlUp))
    rgBM.Offset(1, 0).ClearContents
End With
...

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.