Read Another Excel - way. 1

Sub update_excel()
    Dim x As Integer
    Dim y As Integer
    Dim str_do As String
    Dim int_id As Integer
    Dim str_name As String
    Dim str_sta As String
    Dim str_desc As String
    
    Dim obj As Object
    Set obj = CreateObject("Excel.Application")
    Dim wb As Workbook
    Set wb = obj.Workbooks.Open("C:\Users\Sunny\Desktop\TEST.xlsx")
    Dim sheet As Worksheet
    Set sheet = wb.Sheets("G")
    
    Set sht = ThisWorkbook.Worksheets("Sheet2")
    
    x = 5
    y = 2
    
    Do While sht.Cells(x, 2) <> ""
        str_do = sht.Cells(x, 1)
        int_id = sht.Cells(x, 2)
        str_name = sht.Cells(x, 3)
        str_sta = sht.Cells(x, 4)
        str_desc = sht.Cells(x, 5)
        
        If str_do <> "N" Then
            m_x = int_id + 1
            sheet.Cells(m_x, y).Value = str_name
            sheet.Cells(m_x, y + 1).Value = str_sta
            sheet.Cells(m_x, y + 2).Value = str_desc
        End If
        x = x + 1
    Loop
    
    wb.Close savechanges:=True
    obj.Quit
    
    Set wb = Nothing
    Set obj = Nothing
End Sub

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值