小编use*_*707的帖子

如何使vba代码与libre office兼容

我最近从windows迁移到pclinuxos并且似乎喜欢它.我面临的唯一问题是libreoffice,默认的电子表格包与excel宏不兼容.下面是我的vba代码:

Option VBASupport 
Sub DeleteToLeft()
    Selection.SpecialCells(xlBlanks).Delete shift:=xlToLeft
End Sub
Function SinceLastWash()
    Application.Volatile
    WashCount = 0
    WearCount = 0
    CurrentRow = Application.ThisCell.Row
    For i = 3 To 35
        If Range(Cells(CurrentRow, i), Cells(CurrentRow, i)).Value = "a" Then
            WearCount = WearCount + 1
        End If
        If Range(Cells(CurrentRow, i), Cells(CurrentRow, i)).Value = "q" Then
            WashCount = WashCount + 1
            WearCount = 0
        End If
    Next i
    SinceLastWash = WearCount
End Function
Function testhis()
testhis = Application.ThisCell.Row
End Function
Run Code Online (Sandbox Code Playgroud)

有没有办法转换这个代码,使其与libreoffice兼容,还是我必须学习像python这样的全新语言?学习python不是问题,但不是我的问题的解决方案,因为我在excel中有很多与工作相关的文件,它们有很多vba代码,我不可能在工作中使用开放式办公室/ libreoffice ...

我只想补充一点,函数SinceLastWash在我使用它的某些单元格中给出了正确的值,而在其他单元格中给出了错误,#NAME?

谢谢

excel vba openoffice.org libreoffice

13
推荐指数
2
解决办法
5万
查看次数

如何在vba中对数组中的日期进行排序?

嗨,我是编程新手,刚开始学习VBA for excel.我有关于数组排序的查询.如何对包含日期的数组进行排序?例如,如果我有一个包含日期的数组("23-jul-13","11-jan-10","1-may-09","3-feb-04"),我该如何对这个数组进行排序.我在互联网上搜索了答案,但只能找到排序数字的代码.我已经绞尽脑汁待了2天,但似乎无法得到它.

谢谢

我有下面的代码从选定的列中获取日期,但每次运行它时都会收到错误.我一直试图弄清楚它有什么问题.我之前没有提到过这段代码,因为它会不必要地增加混乱.子GetUniqueAndCount工作正常,但它是sort子,这是问题,因为它不接受作为参数传递给它的数组.

Sub GetUniqueAndCount()
Dim d As Object, c As Range, k, tmp As String

  Set d = CreateObject("scripting.dictionary")
  'I will select the column of dates
 For Each c In Selection
  tmp = Trim(c.Value)
  If Len(tmp) > 0 Then
  If Year(DateValue(Format(tmp, "dd-mmm-yy"))) = 2013 Then
  d(tmp) = d(tmp) + 1
  End If
  End If
  Next c
  i = 0
  ReDim ThisArray(UBound(d.keys)) As Date
  For Each k In d.keys
  ThisArray(i) = DateValue(Format(k, "dd-mmm-yy"))
  i = i + 1 …
Run Code Online (Sandbox Code Playgroud)

arrays sorting excel vba excel-vba

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

excel ×2

vba ×2

arrays ×1

excel-vba ×1

libreoffice ×1

openoffice.org ×1

sorting ×1