Импорт данных Excel в слайды PowerPoint - ошибка времени выполнения '-2147024809 (80070057)': указанное значение выходит за пределы диапазона

Ваш запрос - один из способов выполнения среднего значения:

SELECT t.*,
       (select avg(speed) from tbl tt where tt.timestamp <= t.timestamp) as avg
FROM tbl t;

Альтернативой является использование переменных:

select t.*, (sum_speed / cnt) as running_avg_speed
from (select t.*, (@rn := @rn + 1) as cnt, (@s := @s + speed) as sum_speed
      from tbl t cross join
           (select @rn := 0, @s := 0) params
      order by timestamp
     ) t;

Индекс на tbl(timestamp) должен еще больше улучшить производительность. [/ д2]

1
задан Inge 27 March 2019 в 10:08
поделиться

1 ответ

Из-за комментария Дэвида Земенса о том, что это макрос PPT, я изменил этот ответ. Проблема заключается в использовании функции End (xlup), которая не работает в PPT. Это сработало для меня, но открытие Excel может быть сделано по-вашему, если оно работает для вас.

Sub ReferentieSlides()
    'Open the Excel workbook. Change the filename here.
Dim OWB As Object
    Set OWB = CreateObject("T:\user\me\File.xlsm")

    'Grab the first Worksheet in the Workbook
    Set WS = OWB.Sheets(1)


Set PPTObj = ActivePresentation  'Get the presentation that was opened

    'Loop through each used row in Column A
    'For i = 1 To WS.Range("A10").End(xlUp).Row
    For i = 1 To WS.Range("A1:A10").CurrentRegion.Rows.Count
        'Copy the first slide and paste at the end of the presentation
        PPTObj.Slides(1).Copy
        PPTObj.Slides.Paste (PPTObj.Slides.Count + 1)
        'Change the text of the first text box on the slide.
        PPTObj.Slides(PPTObj.Slides.Count).Shapes(1).TextFrame.TextRange.Text = WS.Cells(i, 1).Value
    Next
End Sub
0
ответ дан mooseman 27 March 2019 в 10:08
поделиться
Другие вопросы по тегам:

Похожие вопросы: