Excel用户定义的函数 [英] Excel User defined Function
问题描述
你能帮助我吗,现在
根据在Excel中编写自定义函数的指南:第二部分自动化加载项 [ ^ ]
当我将用户定义的函数输入到Excel选定单元格时,只有选定的单元格接收值。但我想在输入UDF时更改其他单元格。根据VBA Excel用户定义的函数,以下代码:
模块
函数 Owndefine(a)
Owndefine = a * 10
设置 myc = new css
设置 myc.sht = ActiveSheet
结束 功能
class module css
公共 WithEvent sht 作为工作表
私有 Sub sht_change( ByVal 目标< span class =code-keyword> As 范围)
开 错误 GoTo re n
设置 myc.sht =注意
设置 myc = Nothing
范围( a1:b3)= 1
ren:
End Sub
VBA UDF添加一个事件,因此在输入UDF时可以更改其他单元格。我想要要用C ++实现它,你能给一些帮助,谢谢。
SINK_ENTRY_INFO( 11 ,__ uuidof(MSExcel :: AppEvents),0x61C,& SheetChange,& SheetChangeInfo)
SINK_ENTRY_INFO( 12 ,__ uuidof( MSExcel :: WorkbookEvents),0x61b,& SheetCalculate,& SheetCalculateInfo)
复制VBA menthod,在C ++中,我使用获取UDF的EVNET。没关系。
BEGIN_SINK_MAP(CAddin)
SINK_ENTRY_INFO(1,__ uuidof(_Comma) ndBarButtonEvents),/ * dispid * / 0x01,OnClickBtnCwbb,&OnClickButtonInfo)
SINK_ENTRY_INFO(11,__ uuidof(MSExcel :: AppEvents),0x61C,&SheetChange,&SheetChangeInfo)
SINK_ENTRY_INFO( 12,__ uuidof(MSExcel :: WorkbookEvents),0x61b,&SheetCalculate,&SheetCalculateInfo)
END_SINK_MAP()
// IAddin
public:
// _IDTExtensibility2
void _stdcall SheetCalculate(IDispatch * aa);
void _stdcall SheetChange(IDispatch * Sh,Range * Target);
Can you help me,Now
According Guide to Writing Custom Functions in Excel: Part II Automation Add-In[^]
When I input the User defined function to the Excel selected cell,Only the selected cell receive value. but I want to change the other cells when I input the UDF. According to the VBA Excel User defined Function,Which code following:
Module
Function Owndefine(a)
Owndefine = a*10
Set myc = new css
Set myc.sht = ActiveSheet
End Function
class module css
Public WithEvent sht As Worksheet
Private Sub sht_change(ByVal Target As Range)
On Error GoTo ren
Set myc.sht = Noting
Set myc = Nothing
Range("a1:b3) = 1
ren:
End Sub
The VBA UDF add an Event,So which can change the other cells when inputing the UDF.I want to realize it in C++,can you give some help,thank you .
SINK_ENTRY_INFO(11, __uuidof(MSExcel::AppEvents), 0x61C, &SheetChange, &SheetChangeInfo) SINK_ENTRY_INFO(12, __uuidof(MSExcel::WorkbookEvents), 0x61b, &SheetCalculate, &SheetCalculateInfo)
Copy the VBA menthod,In the C++ ,I Use the EVNET to get the UDF.That's OK.
BEGIN_SINK_MAP(CAddin)
SINK_ENTRY_INFO(1, __uuidof(_CommandBarButtonEvents),/*dispid*/ 0x01, OnClickBtnCwbb, &OnClickButtonInfo)
SINK_ENTRY_INFO(11, __uuidof(MSExcel::AppEvents), 0x61C, &SheetChange, &SheetChangeInfo)
SINK_ENTRY_INFO(12, __uuidof(MSExcel::WorkbookEvents), 0x61b, &SheetCalculate, &SheetCalculateInfo)
END_SINK_MAP()
// IAddin
public:
// _IDTExtensibility2
void _stdcall SheetCalculate(IDispatch *aa);
void _stdcall SheetChange( IDispatch* Sh, Range* Target);
这篇关于Excel用户定义的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!