LibreCalc等效函数到Excel Application.InputBox

时间:2017-04-13 17:16:13

标签: excel-vba basic libreoffice-calc vba excel

我最近转换为使用LibreCalc而不是MS Excel。我想在LibreCalc中使用许多Excel宏,其中一些使用Application.InputBox函数。我在LibreCalc中启用了VBA支持,但遗憾的是该功能无法识别。这是代码示例 -

Rem Attribute VBA_ModuleType=VBAModule
Option VBASupport 1
Sub Project_Data_Sort_By_Date()

Dim x As Long
Dim StartCont As Double
Dim EndCont As Double
Set R = Selection 'Select data range'
RowCnt = R.Rows.Count
colcnt = R.Columns.Count
Set TheTimes = Application.InputBox("Please enter time range: ", "User input", Type:=8) 'Times is corrected full data range of sample period'

在MSExcel中,type = 8的Application.InputBox函数将导致出现一个输入框,这将允许用户在输入框中输入一系列单元格。使用通常的Basic InputBox功能,无法输入单元格范围。

因此,在LibreCalc中是否存在等效函数,或者有不同的方法可以手动选择一系列单元格并将其分配给参数,然后可以在宏中调用它?

1 个答案:

答案 0 :(得分:0)

您可以在CALC中使用相同的运行时函数:

range = Inputbox("Please enter time range:", "User input")
Times = ThisComponent.Sheets().getByIndex(0).getCellRangeByName(range)

您也可以将range作为字符串传递给该函数:

Times = ThisComponent.Sheets().getByIndex(0).getCellRangeByName("B2:C10")