咔片PPT · AI自动生成演示文稿,模板丰富、排版精美 讯飞智文 · 一键生成PPT和Word,高效应对学习与办公

内容导航:


一、wps表格用宏代码计算出现


你拷贝下面 代码试一下吧。“FormulaR1C1”属性用错了,改成“Formula ”就可以。
--------------------------------------------------------------
Sub Macro1()'
' Macro1 Macro'
Columns("A:A").Select
Selection.Delete Shift:=xlShiftToLeft
Columns("C:F").Select
Selection.Delete Shift:=xlShiftToLeft
Cells.Select
Cells.ColumnWidth = 20
Cells.RowHeight = 28.5
Range("D1").Select
Selection.FormulaR1C1 = "佣金"
Range("D2").Select
Selection.FormulaR1C1 = "5"
Rows("1:1").Select
Selection.Insert Shift:=xlShiftDown
Range("E2").Select
Selection.FormulaR1C1 = "合计本金"
Range("E4").Select
Selection.FormulaR1C1 = "佣金"
Range("E3").Select
Selection.Formula = "=SUM(B3:B10000)"
Range("E5").Select
Selection.Formula = "=SUM(D3:D10000)"
Range("E6").Select
Selection.FormulaR1C1 = "合计"
Range("E7").Select
Selection.Formula = "=E3+E5"
Columns("A:F").Select
Selection.HorizontalAlignment = xlHAlignCenter
With Selection.Borders(xlEdgeLeft)
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection.Borders(xlEdgeTop)
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection.Borders(xlEdgeBottom)
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection.Borders(xlEdgeRight)
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection.Borders(xlInsideVertical)
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection.Borders(xlInsideHorizontal)
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Borders(xlEdgeLeft).ColorIndex = xlColorIndexAutomatic
Selection.Borders(xlEdgeTop).ColorIndex = xlColorIndexAutomatic
Selection.Borders(xlEdgeBottom).ColorIndex = xlColorIndexAutomatic
Selection.Borders(xlEdgeRight).ColorIndex = xlColorIndexAutomatic
Selection.Borders(xlInsideVertical).ColorIndex = xlColorIndexAutomatic
Selection.Borders(xlInsideHorizontal).ColorIndex = xlColorIndexAutomatic
Range("E1:E10").Select
With Selection.Font
.Color = 255
.TintAndShade = 0
End With
Selection.Font.Bold = True
Selection.Font.Size = 14
End Sub


二、wps宏编辑器如何写代码


宏是用于扩展WPS功能,可以编写宏代码,来完成WPS中没有的功能,或者提高操作效率。开始wps文字宏功能的步骤如下。

1,打开WPS文字,进入程序主界面。

2,接着,点击上方的开始工具选项,点击打开。

3,在窗口中看到宏功能处于灰色,无法使用。

4,在电脑上打开好的“vba6”文件,点击打开按安装。

5,程序安装完成。

6,最后,回到wps文字中即可看到宏功能启用完成,问题解决。


无论是WPS2016个人免费版,还是最新WPS2019个人免费版,安装后是没有宏vba的功能的。只有专业版才有,但是专业版收费比较贵。今天我们讲解下直接安装WPS宏后可以使用VBA写代码。

1/5打开WPS宏安装包

2/5点击“next”下一步

3/5点击“Igree”下一步

4/5点击“finsh”完成安装

5/5打开WPS,随便打开一个excel表格。点击菜单栏中的开发工具点击VBE编辑器,就可以开始写代码了。