[英]How do I get the right most 3 characters of the formula and not the value of the cell?
[英]How do I append a cell with a formula value?
我正在嘗試使用一個宏來格式化一些數據,以便制定價格表。 當我將信息放入excel時,它可以正常工作,但是一些注釋使它進入了下一行。 這應該采用單元格內容並將其上方的單元格附加到其中。
Sub Macro1()
For i = 8 To 100000
If Left(ActiveSheet.Cells(i + 1, 1).Value, 2) = "AC" Or ActiveSheet.Cells(i + 1, 1).Value = vbNullString Then
Else
If Left(ActiveSheet.Cells(i + 1, 1).Value, 4) = "Page" Then
ActiveSheet.Rows(i + 1).Delete shift:=xlUp
Else
Dim tempString As Variant
tempString = ActiveSheet.Cells(i + 1, 1).Value
ActiveSheet.Cells(i, 1).Value = ActiveSheet.Cells(i, 1).Value + " " + tempString
ActiveSheet.Rows(i + 1).Delete shift:=xlUp
i = i - 1
End If
End If
Next
End Sub
直到遇到單元格值,它都可以正常工作:
=- 4-7
(這實際上不是一個公式,看起來就像一個公式),這給了我一個類型不匹配的錯誤。 我應該使用另一種方式指定單元格內容嗎? 另外,可能有一種更好的方法來指定范圍,我真的只是想一直走到A列。
只需使用.Formula
而不是.Value
這將返回一個常量字符串(如果是常量),或者返回excel認為合適的“公式”字符串。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.