【问题标题】:Having trouble inserting columns - not enough memory插入列时遇到问题 - 内存不足
【发布时间】:2015-09-10 10:27:08
【问题描述】:

我目前正在开发一个宏,它将格式化我们运行的调查问卷的结果以输入到仪表板中。

我需要在电子表格中插入列,但仅限于特定问题之后。我正在使用下面的代码插入列,但是当它到达插入列的部分时,我收到一条错误消息,提示“内存不足”并且 Excel 将关闭。

我目前有 485 列和 1534 行(它是带有多编码问题的受访者级别数据)。

Sub AddingFillerColumns()
    Dim x As Integer
    Dim FCol As Long
    Dim xRange As Range

    Workbooks("WaveData.xlsx").Activate

    FCol = Cells(1, Columns.Count).End(xlToLeft).Column

    For x = 214 To FCol Step 29
        If Cells(1, x).Value Like "Q9*" Then
            Set xRange = Cells(1, x)
                Range(xRange.End(xlDown), xRange).Insert Shift:=xlToRight
                Cells(1, x).Value = "Q9_None"
        End If
    Next x
End Sub

【问题讨论】:

    标签: excel memory vba


    【解决方案1】:

    我无法让你的代码在我身上失败。 也许只是插入列而不是设置 xrange 并确定要插入的范围。

    Sub AddingFillerColumns()
        Dim x As Integer
        Dim FCol As Long
    
        'Workbooks("WaveData.xlsx").Activate
    
        FCol = Cells(1, Columns.Count).End(xlToLeft).Column
    
        For x = 214 To FCol Step 29
            If Cells(1, x).Value Like "Q9*" Then
                Cells(1, x).EntireColumn.Insert
                Cells(1, x) = "Q9_None"
            End If
        Next x
    End Sub
    

    有很多公式吗?

    【讨论】:

    • 完全没有——表本身只有很多数据(或者至少我认为有)。
    猜你喜欢
    • 2019-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-03
    • 1970-01-01
    • 2019-03-18
    相关资源
    最近更新 更多