E đã sửa được thêm 1 chút code nhưng hiện tại vẫn chưa hoạt động được. Nhờ các AC xem giúp e típ với ạ, E cảm ơn
Theo e thì hình như bị sai ở đoạn bôi đỏ có phải ko ạ
Public Sub GetRange()
'Dim variables
Dim FileSelect As Variant
Dim wb As Workbook
Dim Addme As Range, _
CopyData As Range, _
Bk As Range, _
Sh As Range, _
St As Range, _
Fn As Range, _
Tb As Range, _
c As Range
'on error statement
On Error GoTo errHandler:
'hold values in memory
Application.ScreenUpdating = False
'check neccessary cells have values
For Each c In Sheet1.Range("C4,F4:I4")
If c.Value = "" Then
MsgBox "You have left out a value that is needed in " & c.Address
Exit Sub
End If
Next c
'set the range reference variables
Set Bk = UserForm1.TextBox1.Value ' Sheet1.Range("C4") 'file path of book to import from
Set Sh = UserForm1.ComboBox2.Value ' Sheet1.Range("F4") 'sheet to import
Set St = UserForm1.TextBox3.Value ' Sheet1.Range("G4") 'starting cell reference
Set Fn = UserForm1.TextBox4.Value ' Sheet1.Range("H4") 'finishing cell reference
Set Tb = UserForm1.ComboBox1.Value ' Sheet1.Range("I4") 'sheet in this workbook to send it to
'set the destination
'Set Addme = Worksheets(Tb.Value).Range("C" & Rows.Count).End(xlUp).Offset(1, 0)
Set Addme = Worksheets(Tb.Value).Range("C" & [J4])
'open the workbook
Set wb = Workbooks.Open(Bk)
'set the copy range
Set CopyData = Worksheets(Sh.Value).Range(St & ":" & Fn)
'copy and paste the data
CopyData.Copy
Addme.PasteSpecial xlPasteValues
'clear the clipboard
Application.CutCopyMode = False
'close the workbook
wb.Close False
'return to the interface sheet
Sheet1.Select
Application.ScreenUpdating = True
Exit Sub
'error block
errHandler:
MsgBox "An Error has Occurred " & vbCrLf & "The error number is: " _
& Err.Number & vbCrLf & Err.Description & vbCrLf & _
"Please notify the administrator"
End Sub