vba misc 合并表、循环。
来源:互联网 发布:恶作剧软件下载 编辑:程序博客网 时间:2024/05/07 00:37
Option Explicit
'在第7列加上表名
Sub autoadd()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Cells(2, 7).Value = "Country"
ws.Select
Dim rn As Range
ws.Range(ws.Cells(3, 7), Cells(ws.UsedRange.Rows.Count, 7)).Value = ws.Name
Next
End Sub
'合并到一起
Sub t3()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> "compile" Then
ws.Rows("2:" & ws.UsedRange.Rows.Count).Copy Worksheets("compile").Range("a6536").End(xlUp).Offset(2, 0)
End If
Next
End Sub
'检查选中区域是不是有空格
Sub checkblank()
Dim rn As Range
For Each rn In Selection
If Len(rn) = 0 And Len(rn.Offset(0, 1)) = 0 And Len(rn.Offset(0, 2)) = 0 And Len(rn.Offset(0, 3)) = 0 Then
rn.Offset(0, 6).Value = 1
End If
Next
End Sub
'合并单元格 函数
Function tx(rn As Range) As String
Dim str As String
Dim rnn As Range
For Each rnn In rn
If Len(rnn) > 0 Then
str = str & rnn.Text & vbCrLf '加上回车换行
End If
Next
str = Left(str, Len(str) - Len(vbCrLf))
'去掉最后一个回车空格
tx = str
End Function
'合并单元格 过程
Sub ctx()
Dim comstr As String
comstr = tx(Selection)
Dim rnn As Range
For Each rnn In Selection
rnn = ""
Next
Selection.Cells(1, 1) = comstr
End Sub
- vba misc 合并表、循环。
- 通过VBA宏合并Excel工作表
- VBA合并多个excel表
- VBA EXCEL 文件合并
- excel 合并文件 vba
- VBA 合并单元格
- VBA excel文件合并
- 合并表格vba
- 【VBA】单元格合并思路
- VBA 合并当前目录下的工作表
- 通过VBA宏合并Excel工作表(支持复制行数)
- EXCEL VBA 跨表合并多个文件
- vba的宏和模块,关于excel表的合并
- VBA:合并同一文件夹下的所有表
- 【excel VBA】合并当前工作薄下多个sheet表
- vba简单循环详解
- VBA循环生成图表
- VBA-循环赋值CheckBox
- 对游戏研发敏捷之路的一点分享
- JavaScript取得select option value
- 梦呓
- C++ Hello,world
- 动态删除DataRows的数据行,要出错的变相处理方法
- vba misc 合并表、循环。
- 创建XML文档
- 引用—C++ primer
- 区队长杨正祥
- “评论王”活动第3期获奖名单公布!
- Ambition
- 关于类继承的一点小记录!
- c#中抽象类和接口的区别?
- 养成良好编程习惯--编程规范