首页 > 编程语言 > 详细

Excelvba从文件中逐行读取并写入excel中

时间:2019-02-10 21:55:09      阅读:317      评论:0      收藏:0      [点我收藏+]
Sub 読み込む()
    Dim result As Long
    Dim dialog As FileDialog
    Set dialog = Application.FileDialog(msoFileDialogOpen)
    dialog.ButtonName = "開く"
    result = dialog.Show
    If result = -1 Then
        Cells(1, 5).Value = "ファイルが選択されました。" & dialog.SelectedItems.Item(1)
        Open dialog.SelectedItems.Item(1) For Input As #1
        Dim inputstr As String
        Dim counter As Integer
        counter = 2
        Do While Not EOF(1)
            Input #1, inputstr
            Cells(counter, 2).Value = inputstr
            counter = counter + 1
       Loop
       Close #1
    End If
End Sub

Excelvba从文件中逐行读取并写入excel中

原文:https://www.cnblogs.com/jiangwenwen1/p/10360227.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!