VBA学习第五课

Posted yigeduanpian

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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学习第五课的主要内容,如果未能解决你的问题,请参考以下文章

Python 基础 2022 最新第五课 函数

Python 基础 2022 最新第五课 函数

Scrapy学习第五课

PHP走进 PHP 第五课 函数

性能测试学习 第五课

PHP走进 PHP 第五课 函数