Subscript out of range error in this Excel VBA script

前端 未结 3 1520
南旧
南旧 2020-12-20 03:44

I would like to copy data from a CSV file into an Excel worksheet. There are 11 .csv files. So far I have this (it is a modified version from a previous post):



        
3条回答
  •  半阙折子戏
    2020-12-20 04:14

    Set sh1 = Worksheets(filenum(lngPosition)).Activate

    You are getting Subscript out of range error error becuase it cannot find that Worksheet.

    Also please... please... please do not use .Select/.Activate/Selection/ActiveCell You might want to see How to Avoid using Select in Excel VBA Macros.

提交回复
热议问题