码迷,mamicode.com
首页 > 编程语言 > 详细

VBA学习第五课

时间:2018-11-30 00:36:27      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:int   pre   criteria   data   his   book   active   off   vba   

Sub shishi()

Dim rng As Range

For Each rng In Range("b2:b20")
    If rng.Offset(0, -1) = "男" Then
    rng = "先生"
    Else: rng = "女士"
    End If
Next



End Sub

  

Sub shishi()

Dim i As Integer
For i = 1 To Range("a65536").End(xlUp).Row
    If Sheet1.Range("d" & i).Value = "一车间" Then
    Sheet1.Range("d" &i).EntireRow.CopySheet2.Range("a"&Range("a65536").End(xlUp).Row)
    End If
Next




End Sub

  

Sub aaa()
Dim sht As Worksheet
Dim i As Integer
    For i = 2 To Sheet1.Range("a65536").End(xlUp).Row
    Sheet1.Range("d" & i).EntireRow.Copy Sheets(Sheet1.Range("d" & i).Value).Range("a" & Sheets(Sheet1.Range("d" & i).Value).Range("a65536").End(xlUp).Row + 1)
    
    
    Next
    
    For Each sht In Worksheets
    sht.Copy
    ActiveWorkbook.SaveAs Filename:="d:\data\" & sht.Name & ".xlsx"
    ActiveWorkbook.Close

    Next
End Sub

  

Sub 宏1()


Dim sht As Worksheet
    For Each sht In Sheets(Array("一车间", "二车间", "财务部", "销售1部", "经理室", "人力资源部", "销售2部", "技改办"))
    
       Sheet1.Range("a1").Resize.AutoFilter Field:=4, Criteria1:=sht.Name
       Sheet1.Range("a1").Resize(Sheet1.Range("a65536").End(xlUp).Row, 6).Copy Sheets(sht.Name).Range("a1")
    
    sht.Copy
    ActiveWorkbook.SaveAs Filename:="d:\data\" & sht.Name & ".xlsx"
    ActiveWorkbook.Close
Next
End Sub

  

VBA学习第五课

标签:int   pre   criteria   data   his   book   active   off   vba   

原文地址:https://www.cnblogs.com/yigeduanpian/p/10041736.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!