Page 1 of 1

VBA to Eviews

Posted: Mon Jun 22, 2020 6:23 pm
by Elderfield.A
Hi,

I am writing some VBA to take data from excel into eviews:

Code: Select all


Dim shReadMe  As Worksheet, shWorkingAdd As Worksheet
    Dim mgr As New EViews.Manager
    Dim app As EViews.Application
    Dim Path As String, SeriesName As String
    Dim rngAdjustedProfile As Range
       
    Set shReadMe = Worksheets("READ ME")
    Set shWorkingAdd = Worksheets("Working AddFactors")
    Set app = mgr.GetApplication(ExistingOrNew)
    Path = shReadMe.Range("PATH")
    Set rngAdjustedProfile = shWorkingAdd.Range("Q8:X8")
    SeriesName = shWorkingAdd.Range("VARIABLE")
   
   
    app.Run "wfopen """ & Path & "\output\Model.wf1"""
    app.Run "smpl 2020q2 2022q2"
    app.Put SeriesName, rngAdjustedProfile, DataTypeSeries
    app.Show




Everything works, except the app.put call doesnt seem to read in the range of data, but only the first observation, so in this instance the data in cell Q8 in shWorkingAdd. I have changed the cell reference and every time it is the same, reading in only the first observation in the range - NAs for everything else.

I also have tried app.PutSeries with no avail.

I am using Eviews 10+ and Excel 2016.

Any thoughts as to where I am going wrong?

Re: VBA to Eviews

Posted: Mon Jun 22, 2020 8:42 pm
by Elderfield.A
Turns out this is happening because my range runs across columns. It appears that for this to work I need the data to be transposed:

I have changed this

Code: Select all

Dim rngAdjustedProfile As Variant, rngAdjustedProfileT as Variant


And this

Code: Select all

rngAdjustedProfile = shWorkingAdd.Range("AdjustedProfile").Value2
rngAdjustedProfileT = Application.Transpose(rngAdjustedProfile)


Which seems to work!

However, I would be interested to know if this was indeed the issue, and if there is a better work around?

Re: VBA to Eviews

Posted: Tue Jun 23, 2020 7:09 am
by EViews Steve
EViews reads and writes a series object vertically. So transpose is the solution we recommend to people who have their data running horizontally.

Re: VBA to Eviews

Posted: Tue Jun 23, 2020 8:52 am
by EViews Gareth
EViews Steve wrote:EViews reads and writes a series object vertically. So transpose is the solution we recommend to people who have their data running wrongly.


Fixed that for you.

Re: VBA to Eviews

Posted: Tue Jun 23, 2020 4:11 pm
by Elderfield.A
Thanks for the useful responses Steve and Gareth - personal opinions around which way data should run when people set up spreadsheets aside, it would be a nice feature to have in future. I also couldn't find any reference to this little quirk in the white paper (although I could have missed it) - are there any other quirks that are not documented that would be useful to know?