我有一个单独的工作表Sheet1和Sheet2,我试图引用从Sheet2到Sheet1的一系列单元格
我知道如何引用工作表单元格,=Sheet2!A1 但是如何对单元格区域执行相同的操作,例如A1:F1我尝试=Sheet2!A1:F1但不喜欢语法.
如果可能的话,我需要使用Excel公式.
小智 6
简单---
我创建了一个带有4个单元格的Sheet 2和带有一个Formula的单个Cell的Sheet 1:
=SUM(Sheet2!B3:E3)
Run Code Online (Sandbox Code Playgroud)
请注意,尝试按照您的说法,为单个单元格指定一个范围内的值是没有意义的.将其发送到使用范围对其执行某项操作的公式.
好的,明白了,我下载了一个自定义串联函数,然后引用了它的单元格
代码
Function concat(useThis As Range, Optional delim As String) As String
' this function will concatenate a range of cells and return one string
' useful when you have a rather large range of cells that you need to add up
Dim retVal, dlm As String
retVal = ""
If delim = Null Then
dlm = ""
Else
dlm = delim
End If
For Each cell In useThis
if cstr(cell.value)<>"" and cstr(cell.value)<>" " then
retVal = retVal & cstr(cell.Value) & dlm
end if
Next
If dlm <> "" Then
retVal = Left(retVal, Len(retVal) - Len(dlm))
End If
concat = retVal
End Function
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
98099 次 |
| 最近记录: |