LibreCalc 等效函数 Excel Application.InputBox.



我最近改用LibreCalc而不是MS Excel。我有许多 Excel 宏想在 LibreCalc 中使用,其中一些使用 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 函数将导致出现一个输入框,并允许用户在输入框中输入一系列单元格。使用通常的基本输入框功能,无法输入单元格范围。

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

您可以在 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")

最新更新