Hi,
Please check the code:
Function GetValuesFromAClosedWorkbook(fPath, fName, sName, c_Rng, b_Rng As String)
With ActiveSheet.Range(b_Rng)
.FormulaArray = "='" & fPath & "\[" & fName & "]" & sName & "'!" & c_Rng
.Value = .Value
End With
End Function
Sub GetData()
Sheets("RawData").UsedRange.Clear
Sheets("RawData").Activate
GetValuesFromAClosedWorkbook "C:\Oncology\tmp\", "AFRB_TERR_DATA.xlsx", "AFRB_TERR_DATA", "A1:JN150", "A1:JN150"
Sheets("RawData").Activate
x = Columns("a").Cells.Find(What:="0", LookAt:=xlWhole, LookIn:=xlValues).Row
y = ActiveSheet.UsedRange.Rows.Count
col = ActiveSheet.UsedRange.Columns.Count
Range(Cells(x, "a"), Cells(y, col)).Clear
End Sub
As I run the code, get error on "x=Columns("a").Cells.Find...." simply because the data I get from AFRB_TERR_DATA.xlsx all turns into "#REF!". But why?
I checked the source tab, the data are perfectly OK. But it has lots of columns (274). It cannot be memory problems, can it? The funny thing is that sometimes
it comes out fine; but most times, it's just #REF!.
Thanks in advance.
Please check the code:
Function GetValuesFromAClosedWorkbook(fPath, fName, sName, c_Rng, b_Rng As String)
With ActiveSheet.Range(b_Rng)
.FormulaArray = "='" & fPath & "\[" & fName & "]" & sName & "'!" & c_Rng
.Value = .Value
End With
End Function
Sub GetData()
Sheets("RawData").UsedRange.Clear
Sheets("RawData").Activate
GetValuesFromAClosedWorkbook "C:\Oncology\tmp\", "AFRB_TERR_DATA.xlsx", "AFRB_TERR_DATA", "A1:JN150", "A1:JN150"
Sheets("RawData").Activate
x = Columns("a").Cells.Find(What:="0", LookAt:=xlWhole, LookIn:=xlValues).Row
y = ActiveSheet.UsedRange.Rows.Count
col = ActiveSheet.UsedRange.Columns.Count
Range(Cells(x, "a"), Cells(y, col)).Clear
End Sub
As I run the code, get error on "x=Columns("a").Cells.Find...." simply because the data I get from AFRB_TERR_DATA.xlsx all turns into "#REF!". But why?
I checked the source tab, the data are perfectly OK. But it has lots of columns (274). It cannot be memory problems, can it? The funny thing is that sometimes
it comes out fine; but most times, it's just #REF!.
Thanks in advance.