ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 效率神器,一键搞定繁琐工作
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
让更多数据处理,一键完成 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
楼主: djt

10年VBA经验,闲着没事找事干;你出题,我来做,闲着也是闲着

  [复制链接]

TA的精华主题

TA的得分主题

发表于 2012-9-4 17:30 | 显示全部楼层
高手无处不在,学习不断向前!

TA的精华主题

TA的得分主题

发表于 2012-9-14 09:13 | 显示全部楼层

两个支持VBA的软件之间来回操作

本帖最后由 amos7839 于 2012-9-14 09:19 编辑

做个小程序,需要在两个支持VBA的软件之间来回操作,不知道只用VBA能不能实现。具体过程如下:在AutoCAD里点击菜单,使用VBA启动Excel,然后在Excel中打开或新建文件并编辑,完成后选择部分数据再点击Excel中的菜单或命令按钮使用VBA返回到AutoCad中绘图。希望能给出一些指导,或者推荐几本参考书,谢谢!

TA的精华主题

TA的得分主题

发表于 2012-9-25 20:11 | 显示全部楼层
请教老师:这是一个23行自动分页小计累计的代码,假若要改为25行和30行自动分页小计,要改那个值?谢谢!
Sub a增加小计()
Do
bt = Application.InputBox(prompt:="请输入要求和的列,用数字表示。" & Chr(13) & "如D列则输入4,多列用半角“,”分开:", Title:="输入需要求和的列")
If bt = False Then Exit Sub
bt = bt & ","
For k = 1 To Len(bt) - 1
b = Mid(bt, k, WorksheetFunction.Find(",", bt, k) - k)
If b > 1 And b < 257 Then
Else
MsgBox "输入列数格式错误,请重新输入!", vbOKOnly, "错误"
Exit For
End If
k = k + Len(b)
Next k
Loop Until k > Len(bt)
k = 0
Do
k = k + 1
If k > 50 Then MsgBox "未找到起始行。(A列序号为1的那行)", vbOKOnly, "失败": Exit Sub
Loop Until Cells(k, 1) = 1
Application.ScreenUpdating = False
For j = 4 To Range("A65536").End(xlUp).Row
If Cells(j, 1) = "本页小计" Or Cells(j, 1) = "累计" Or Cells(j, 1) = "总计" Then
Rows(j).Delete shift:=xlUp
j = j - 1
End If
Next j
Rows(j - 2 & ":" & j - 1).Copy Destination:=Range("A" & j)
Range("A" & j & ":O" & j + 1).ClearContents
Cells(j, 1) = "本页小计"
Cells(j + 1, 1) = "总计"
Rows(j & ":" & j + 1).Font.Bold = True
ActiveWindow.View = xlPageBreakPreview
For r = 1 To 2
For i = 1 To ActiveSheet.HPageBreaks.Count
Set hb = ActiveSheet.HPageBreaks(i).Location
If hb.Offset(-2, 0) <> "本页小计" Then
hb.Offset(-2, 0).EntireRow.Insert
hb.Offset(-2, 0).EntireRow.Insert
hb.Offset(-4, 0) = "本页小计"
hb.Offset(-3, 0) = "累计"
Rows(hb.Offset(-4, 0).Row & ":" & hb.Offset(-3, 0).Row).Font.Bold = True
For m = 1 To Len(bt) - 1
b = Mid(bt, m, WorksheetFunction.Find(",", bt, m) - m)
If i = 1 Then sh = "A" & k Else: sh = ActiveSheet.HPageBreaks(i - 1).Location.Address(0, 0)
hb.Offset(-4, b - 1) = "=SUBTOTAL(9," & Range(sh).Offset(0, b - 1).Address(0, 0) & ":" & hb.Offset(-5, b - 1).Address(0, 0) & ")"
hb.Offset(-3, b - 1) = "=SUBTOTAL(9," & Range("A" & k).Offset(0, b - 1).Address(0, 0) & ":" & hb.Offset(-5, b - 1).Address(0, 0) & ")"
m = m + Len(b)
Next m
End If
Next i
Next r
For m = 1 To Len(bt) - 1
b = Mid(bt, m, WorksheetFunction.Find(",", bt, m) - m)
If i = 1 Then sh = "A" & k Else: sh = ActiveSheet.HPageBreaks(i - 1).Location.Address(0, 0)
zc = Range("A65536").End(xlUp).Row
Cells(zc, 1).Offset(-1, b - 1) = "=SUBTOTAL(9," & Range(sh).Offset(0, b - 1).Address(0, 0) & ":" & Cells(zc, 1).Offset(-2, b - 1).Address(0, 0) & ")"
Cells(zc, 1).Offset(0, b - 1) = "=SUBTOTAL(9," & Range("A" & k).Offset(0, b - 1).Address(0, 0) & ":" & Cells(zc, 1).Offset(-2, b - 1).Address(0, 0) & ")"
m = m + Len(b)
Next m
ActiveWindow.View = xlNormalView
Application.ScreenUpdating = True
End Sub
Sub a删除小计()
Application.ScreenUpdating = False
For i = 4 To Range("A65536").End(xlUp).Row
If Cells(i, 1) = "本页小计" Or Cells(i, 1) = "累计" Or Cells(i, 1) = "总计" Then
Rows(i).Delete shift:=xlUp
i = i - 1
End If
Next i
Application.ScreenUpdating = True
End Sub

TA的精华主题

TA的得分主题

发表于 2012-9-25 20:10 | 显示全部楼层
请教老师:这是一个23行自动分页小计累计的代码,假若要改为25行和30行自动分页小计,要改那个值?谢谢!
Sub a增加小计()
Do
bt = Application.InputBox(prompt:="请输入要求和的列,用数字表示。" & Chr(13) & "如D列则输入4,多列用半角“,”分开:", Title:="输入需要求和的列")
If bt = False Then Exit Sub
bt = bt & ","
For k = 1 To Len(bt) - 1
b = Mid(bt, k, WorksheetFunction.Find(",", bt, k) - k)
If b > 1 And b < 257 Then
Else
MsgBox "输入列数格式错误,请重新输入!", vbOKOnly, "错误"
Exit For
End If
k = k + Len(b)
Next k
Loop Until k > Len(bt)
k = 0
Do
k = k + 1
If k > 50 Then MsgBox "未找到起始行。(A列序号为1的那行)", vbOKOnly, "失败": Exit Sub
Loop Until Cells(k, 1) = 1
Application.ScreenUpdating = False
For j = 4 To Range("A65536").End(xlUp).Row
If Cells(j, 1) = "本页小计" Or Cells(j, 1) = "累计" Or Cells(j, 1) = "总计" Then
Rows(j).Delete shift:=xlUp
j = j - 1
End If
Next j
Rows(j - 2 & ":" & j - 1).Copy Destination:=Range("A" & j)
Range("A" & j & ":O" & j + 1).ClearContents
Cells(j, 1) = "本页小计"
Cells(j + 1, 1) = "总计"
Rows(j & ":" & j + 1).Font.Bold = True
ActiveWindow.View = xlPageBreakPreview
For r = 1 To 2
For i = 1 To ActiveSheet.HPageBreaks.Count
Set hb = ActiveSheet.HPageBreaks(i).Location
If hb.Offset(-2, 0) <> "本页小计" Then
hb.Offset(-2, 0).EntireRow.Insert
hb.Offset(-2, 0).EntireRow.Insert
hb.Offset(-4, 0) = "本页小计"
hb.Offset(-3, 0) = "累计"
Rows(hb.Offset(-4, 0).Row & ":" & hb.Offset(-3, 0).Row).Font.Bold = True
For m = 1 To Len(bt) - 1
b = Mid(bt, m, WorksheetFunction.Find(",", bt, m) - m)
If i = 1 Then sh = "A" & k Else: sh = ActiveSheet.HPageBreaks(i - 1).Location.Address(0, 0)
hb.Offset(-4, b - 1) = "=SUBTOTAL(9," & Range(sh).Offset(0, b - 1).Address(0, 0) & ":" & hb.Offset(-5, b - 1).Address(0, 0) & ")"
hb.Offset(-3, b - 1) = "=SUBTOTAL(9," & Range("A" & k).Offset(0, b - 1).Address(0, 0) & ":" & hb.Offset(-5, b - 1).Address(0, 0) & ")"
m = m + Len(b)
Next m
End If
Next i
Next r
For m = 1 To Len(bt) - 1
b = Mid(bt, m, WorksheetFunction.Find(",", bt, m) - m)
If i = 1 Then sh = "A" & k Else: sh = ActiveSheet.HPageBreaks(i - 1).Location.Address(0, 0)
zc = Range("A65536").End(xlUp).Row
Cells(zc, 1).Offset(-1, b - 1) = "=SUBTOTAL(9," & Range(sh).Offset(0, b - 1).Address(0, 0) & ":" & Cells(zc, 1).Offset(-2, b - 1).Address(0, 0) & ")"
Cells(zc, 1).Offset(0, b - 1) = "=SUBTOTAL(9," & Range("A" & k).Offset(0, b - 1).Address(0, 0) & ":" & Cells(zc, 1).Offset(-2, b - 1).Address(0, 0) & ")"
m = m + Len(b)
Next m
ActiveWindow.View = xlNormalView
Application.ScreenUpdating = True
End Sub
Sub a删除小计()
Application.ScreenUpdating = False
For i = 4 To Range("A65536").End(xlUp).Row
If Cells(i, 1) = "本页小计" Or Cells(i, 1) = "累计" Or Cells(i, 1) = "总计" Then
Rows(i).Delete shift:=xlUp
i = i - 1
End If
Next i
Application.ScreenUpdating = True
End Sub
自动分页小计累计.rar (21.39 KB, 下载次数: 19)

TA的精华主题

TA的得分主题

发表于 2012-10-10 17:05 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2012-10-25 22:11 | 显示全部楼层
“心”的体会,我亦有同感啊

TA的精华主题

TA的得分主题

发表于 2012-10-31 22:19 | 显示全部楼层
这样持续到2007年,开始接手生产计划。库存有了,BOM有了,生产有了,还缺什么呢?预测!那就往销售MM要预测数据吧,根据历史12个月发货记录,把预测分拆成详细的产品(客户固定,产品比例固定)。库存+生产+已销售-预测-安全库存=我要给车间的生产单,简单。生产单放到系统,车间计划员运行拉料单,产生原材料需求。
高手 能把你做的这个表发给我吗?非常感谢!!

TA的精华主题

TA的得分主题

发表于 2012-11-8 08:35 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2012-12-16 12:18 | 显示全部楼层
本帖最后由 莫悠悠 于 2012-12-16 12:23 编辑

毛主席教导我们:在战争中学习战争!我也不是学专科出身,但是就是对VBA产生了浓厚兴趣,也解决了不少问题,我现在的阶段是采购零部件,自建组装车间,这样做的后果是代码繁杂,运算速度慢,没办法,没到哪个级别。
在此想请教版主:输入会计凭证的时候,特别是转账凭证,行数都在50行左右,怎样实现凭证自动分页?1/50,2/50,3/50,4/50……

TA的精华主题

TA的得分主题

发表于 2012-12-18 17:05 | 显示全部楼层
小弟是个新手,现在我要设置:1.打印同个文档里2个SHEET的文件;2把这2个SHEET的文件另存为一个新的文档:A.该2个SHEET以前是公式,现在不要公式了,只要值,结构还一致;B新文档的名字用指定单元格命名,位置的捷径也放在个单元格。要怎么设置,谢谢
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-12-22 11:50 , Processed in 0.037565 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表