Home > Software engineering >  Definition of array beyond how to handle
Definition of array beyond how to handle

Time:11-15


Sub LoadExcelData ()
Dim WKBK As Workbook 'work to define a thin
Dim myFileName As String 'definition to read the file path
Dim dataRow As Integer 'define the data lines
Dim dataColumn As Integer 'define data column
Dim rgRC As String 'read the content of cells (dataRow, dataColumn)
Dim arr (3 To 10, 1 To 9) As String 'definition of a two dimensional array
'myFileName=Application. GetOpenFilename (" EXCEL file (*. XLSX), *. XLS ")' browse the file, such as XX to XX company 17 years table. XLS
If myFileName="False" Then "If cancel the pop-up dialog
MsgBox "please select a file!" , vbInformation, "cancel"
The Else
The Set WKBK=Workbooks. Open (myFileName) 'first Open to copy the file

WKBK. Activate 'Activate open workbook

For dataRow=3 To 10 'set the range
For dataColumn=1 To 9 'set column range
Sheets (" sheet1 "). Activate
) is rgRC=Cells (dataRow, dataColumn as'
Arr (dataRow, dataColumn)=Cells (dataRow, dataColumn)
Next dataColumn
Next dataRow

Sheets (" Sheet3 "). Activate
WKBK. Close False 'Close work thin
For dataRow=3 To 10
For dataColumn=1 To 9
Cells (dataRow, dataColumn)=arr (dataRow, dataColumn)
Next dataColumn
Next dataRow
MsgBox "data import success!"
End the If
End Sub


CodePudding user response:

Please describe the problem, it is best to put the question point out the location of the error

CodePudding user response:

There is no error, data can be normal import
  •  Tags:  
  • VBA
  • Related