简体   繁体   English

运行时错误“ 1004”无法设置范围的文本属性

[英]Run-time error '1004' Unable to set the Text Property of Range

I am trying to store data from "details" sheet into strings from different columns to different strings for every row in a linear manner and then assign the strings the same value 51 times in Cells of other sheet named "output". 我试图以线性方式将数据从“详细信息”表存储到字符串中,从不同的列到每一行的不同字符串,然后在名为“输出”的其他工作表的单元格中为字符串分配相同的值51次。

Option Explicit

Sub Arrange()
Dim FinalRow, FinalRow1 As Long
Dim ws, wr As Worksheet
Dim strCN, strAdd, strCity, strState, strZip, strPhone, strWeb As String
Application.ScreenUpdating = False
Dim i, j As Long


Set ws = Sheets("details")
FinalRow = ws.Range("A900000").End(xlUp).Row

For j = 2 To FinalRow

    strCN = Cells(j, "A")
    strAdd = Cells(j, "H")
    strCity = Cells(j, "I")
    strState = Cells(j, "J")
    strZip = Cells(j, "K")
    strPhone = Cells(j, "R")
    strWeb = Cells(j, "U")

    Set wr = Sheets("output")
    FinalRow1 = wr.Range("A900000").End(xlUp).Row
    For i = FinalRow1 To FinalRow1 + 51
        With Sheets("output")
            Cells(i, "A").Text = strCN       'Error Line
            Cells(i, "B").Text = strAdd
            Cells(i, "C").Text = strCity
            Cells(i, "D").Text = strState
            Cells(i, "E").Text = strZip
            Cells(i, "F").Text = strPhone
            Cells(i, "G").Text = strWeb
        End With
    Next i
Next j

End Sub

As per our conversation above. 根据我们上面的谈话。 I have made the changes I suggested. 我已经进行了建议的更改。

The last problem was that the details sheet was not being called and if the other sheet was active at the time it was looking at empty cells. 最后一个问题是没有调用详细信息表,并且如果另一个表在查看空单元格时处于活动状态。

Dim FinalRow, FinalRow1 As Long
Dim ws, wr As Worksheet
Dim strCN, strAdd, strCity, strState, strZip, strPhone, strWeb As String
Application.ScreenUpdating = False
Dim i, j As Long


Set ws = Sheets("details")
FinalRow = ws.Range("A900000").End(xlUp).Row

For j = 2 To FinalRow
    With ws
        strCN = .Cells(j, "A")
        strAdd = .Cells(j, "H")
        strCity = .Cells(j, "I")
        strState = .Cells(j, "J")
        strZip = .Cells(j, "K")
        strPhone = .Cells(j, "R")
        strWeb = .Cells(j, "U")
    End With
    Set wr = Sheets("output")
    FinalRow1 = wr.Range("A900000").End(xlUp).Row
    For i = FinalRow1 To FinalRow1 + 51
        With Sheets("output")
            .Cells(i, "A").Value = strCN       'Error Line
            .Cells(i, "B").Value = strAdd
            .Cells(i, "C").Value = strCity
            .Cells(i, "D").Value = strState
            .Cells(i, "E").Value = strZip
            .Cells(i, "F").Value = strPhone
            .Cells(i, "G").Value = strWeb
        End With
    Next i
Next j
Application.ScreenUpdating = True

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 运行时错误:1004无法设置Range类的FormulaArray属性 - Run-time error: 1004 Unable to set the FormulaArray property of the Range Class 运行时错误“1004”无法设置范围类的 NumberFormat 属性 - Run-time error '1004' Unable to set the NumberFormat property of Range Class Excel - 运行时错误“1004”:无法设置范围类的隐藏属性 - Excel - Run-time error '1004': Unable to set the hidden property of the range class 运行时错误 1004 无法设置范围类的隐藏属性 - run time error 1004 unable to set the hidden property of the range class 运行时错误:无法设置范围 Class 的 FormulaArray 属性 - Run-time Error: Unable to set the FormulaArray property of the Range Class 运行时错误1004无法获取工作表的countif属性 - run-time error 1004 unable to get countif property of the worksheet 运行时错误1004无法设置DrawingObjects类的visible属性 - Run-time Error 1004 unable to set the visible property of the DrawingObjects class 运行时错误1004:无法设置PivotItem类的Name属性 - Run-time error 1004: Unable to set the Name property of PivotItem class 运行时错误'1004':无法在VBA中设置边框类的线条样式属性 - Run-time error '1004': Unable to set line style property of border class in VBA 运行时错误'1004':无法设置OLEObject类的enabled属性 - Run-time error '1004': Unable to set the enabled property of the OLEObject class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM