excel:Dim xDoc As DOMDocument处报错“用户定义类型未定义”
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了excel:Dim xDoc As DOMDocument处报错“用户定义类型未定义”相关的知识,希望对你有一定的参考价值。
在旧电脑excel2007上可用,在另外一台2007上不能用,在office365上不能用。。。
DOMDocument不是软件自带的类型,是自定义类型。
你得先有这个类型,才能定义这个类型。
excel怎样把空格里,自动添加上序列号
Dim rng As Range, rng1 As Range, rng2 As Range, Num As Double, nc As Double, nr As Double, i As Double, j As Double
Set rng1 = Range("a1").End(xlToRight)
Set rng2 = Range(Range("a1"), rng1)
nc = rng2.Columns.Count
nr = ActiveSheet.UsedRange.Rows.Count
For i = 1 To nc
If Cells(1, i) = 1 Then
For j = 2 To nr
If Cells(j, i) = "" And Application.WorksheetFunction.IsNumber(Cells(j - 1, i)) = True Then
Cells(j, i) = Cells(j - 1, i) + 1
Else
If Cells(j, i) = "" And Application.WorksheetFunction.IsNumber(Cells(j - 1, i)) = False Then
Cells(j, i) = 1
End If
End If
Next
End If
Next
End Sub
欢迎追问,满意请采纳哦。
使用方法:按Alt+F11打开VBE界面,插入,模块,复制粘贴以上代码,关闭当前VBE界面,按Alt+F8,执行代码就OK啦。你把表格保存为xls或者xlsm格式,以后都只要Alt+F8一下就好了。
是
追答按Alt+F11,在工作表对应的窗口复制代码:
Sub 空格自动编号()
Dim RowNum As Double, ColNum As Double, Num As Double, Num1 As Double
RowNum = ActiveSheet.UsedRange.Rows.Count
ColNum = ActiveSheet.UsedRange.Columns.Count
For i = 2 To ColNum
Num = 0
Num1 = 1
If Cells(1, i) = 1 Then
Num = 1
Num1 = 2
End If
For j = Num1 To RowNum
If Cells(j, i).Value = "" Then
Num = Num + 1
Cells(j, i) = Num
Else
Cells(j, i) = Cells(j, i)
Num = 0
End If
Next j
Next i
End Sub
这是所有空白单元格都会自动编号的!!
你上传个excel文件的话,可以做的更好
回到工作表按ALt+F8 运行那个代码
我要的效果就是,B列里那样的,都是一千以内的数字
追答我已经实现了,要表的话留QQ或者邮箱呀
———————分割线实现过程———————————
原表如下
新增辅助表
辅助表函数如下:
A2单元格公式:=IF(Sheet1!A2="","",Sheet1!A2)
B2单元格公式:=IF($A2="","",IFERROR(IF(Sheet1!B2="",Sheet4!B1+1,Sheet1!B2),1))
往下一拉,往右一拖就可以了。
形成原表的公式还复杂些
———————原表实现过程分割线———————————
原表B2单元格:=IF($A2="","",IF(ROUNDDOWN($A2/100,0)=B$1,TEXT(INT(ABS(B$1)),"[dbnum2]"),""))
原表L2单元格:=IF($A2="","",IF(MOD(ROUNDDOWN($A2/10,0),10)=L$1,TEXT(INT(ABS(L$1)),"[dbnum2]"),""))
原表V2单元格:=IF($A2="","",IF(MOD($A2,10)=V$1,TEXT(INT(ABS(V$1)),"[dbnum2]"),""))
三个单元格各种下拉右拉,复制粘贴第一行换成1就OK啦




以上是关于excel:Dim xDoc As DOMDocument处报错“用户定义类型未定义”的主要内容,如果未能解决你的问题,请参考以下文章
在excel中使用VBA如何同一个工作簿下工作表内的数据移到另一个工作表指定位置请大神指点