0

I have some VBA in an Excel 2010 document which returns "nothing" when I try to assign a range from a different worksheet. I can reference the value of a cell within the range with no problems.

Why does the code below leave the rng variable set to Nothing, when the value of s3 correctly contains the value of the first cell in that range??

Dim s3 As String
    Dim rng As Range

    Set SourceFile = Application.Workbooks.Open("c:\finance\inv.xls")
    Set SourceSheet = SourceFile.Worksheets(Source)

    s3 = SourceSheet.Range("A3").Value
    rng = SourceSheet.Range("A3:A30")
Ian M
  • 567
  • 8
  • 33

1 Answers1

0

Use

Set rng = SourceSheet.Range("A3:A30")

I do not understand why you do not get the error message

Object variable or With block variable not set

Are you using On Error Resume Next to suppress errors?

Barry
  • 3,683
  • 1
  • 18
  • 25
  • Thanks. That's resolved the issue but the problem that the code above was helping me to debug remains! I'll post a separate question for that, as I've run out ideas – Ian M Oct 20 '14 at 17:58