Sub 将所有列全部转换为文本() t=timer 'Cells(Rows.Count, 1).End(xlUp).Row 获取第一列最后一个非空单元格的行号 s = Cells(, Columns.Count).End(xlToLeft).Column '获取第一行最后一个非空单元格的列号 For i = To s Columns(i).Select Selection.TextToColumns Destination:=Cells(, i), DataType:=xlDelimited,
Sub 表格单元格替换文字() If MsgBox("确定要替换单元格的文字吗?", vbYesNo + vbQuestion) = vbYes Then To ActiveDocument.Tables.Count , Column:=).Range .Delete .InsertAfter Text:="XXX" End With , Column:=).Range .Delete .InsertAfter Text:="与预期结果一致" E
封装函数: Sub 插入产品形象(strRange As String, datebaseTu As String) Dim strJpg As String strJpg = datebaseTu '... .jpg If Dir(strJpg, vbDirectory) <> "" Then ActiveSheet.Pictures.Insert(strJpg).Select Dim cT As Single Dim cL As Single Dim cW As Sin
Sub test1() Dim h Dim j As Integer j = 0 '用于辅助循环的进行,可以在拆分行获取下一个需要拆分单元格的行号 'Application.ScreenUpdating = False 'For i = 1 To Range("a65536").End(xlUp).Row For i = 1 To 50 '循环结束值至少等于拆分后的行数,否则会没有分完就跳出循环,导致最后部分无法拆分 'MsgBox
Function ISFORMULA(ByVal rg As Object) As Variant Dim temp As Variant Dim i As Integer, j As Integer temp = rg.Formula If IsArray(temp) Then For i = 1 To UBound(temp, 1) For j = 1 To UBound(temp, 2)
Sub test() Dim str Dim i, j i = j = ).UsedRange.Rows.Count ).UsedRange.Columns.Count ).Cells(r, c).Value Worksheets().Cells(j, ).Value = i Worksheets().Cells(j, ).Value = c Worksheets().Cells(j, ).Value = str j = j + Next i = i + Next End Sub 删除形状 Su
准备工作: 1.首先需要提供一个word模板,并且标记好您要插入书签的位置,定义书签的命名.如图 2.模拟您要插入的Excel原始数据和图表对象 插入代码如下: Private Sub CommandButton1_Click() Dim App, WrdDoc, Mypath As String On Error Resume Next '定义原始模板的储存路径,默认和excel在同一路径 Mypath = ThisWorkbook.Path & "\模板.doc" '用Se
Excel里使用VBA对已经合并的单元格添加注释,直接使用AddComment会报: 运行时错误 '1004':应用程序定义或者对象定义错误 找了很多文章都没找到怎么解决,最后发现在AddComment之前,先ClearComments一下,就好了 Excel using vba to add comment to a merged cell if occur runtime error 1004, before invoking addcomment, first invoke ClearC