Tuesday 19 November 2019

excel - Range is set to nothing but cell references within range are valid

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")

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...