0% found this document useful (0 votes)
15 views1 page

Excel VBA File Picker and Data Import

Uploaded by

echduy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views1 page

Excel VBA File Picker and Data Import

Uploaded by

echduy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Sub get_result()

Dim filedlg As FileDialog


Set filedlg = [Link](msoFileDialogFilePicker)
With filedlg
.AllowMultiSelect = False
.Title = "CHON MAU CAN LAY KET QUA"
.InitialFileName = "C:\Chem32\1\DATA" & "\"
.[Link]
'.[Link] "Excel", "*.xls?"
If .Show = True Then
docdulieu2 (.SelectedItems(1))
End If
End With
Set filedlg = Nothing
End Sub
Sub docdulieu2(duongdan As String)
Dim lstRow As Long
Dim wb_active As Workbook
Dim ws_active As Worksheet
Dim wb_close As Workbook
Dim ws_close As Worksheet
Dim samplename As String
Set wb_active = ActiveWorkbook
[Link] = False
Set wb_close = [Link](duongdan, True, True)

Set ws_close = wb_close.Sheets("Compound")


Set ws_active = wb_active.Sheets("Raw_result")
ws_close.Range("M:N").Copy Destination:=ws_active.Range("A:B")

Set ws_close = wb_close.Sheets(1)


Set ws_active = wb_active.Sheets("Raw_result")

ws_close.Range("B21").Copy Destination:=ws_active.Range("D1")
'---------------
wb_close.Close False
Set wb_close = Nothing
samplename = ws_active.Range("D1").Value
result = MsgBox("DAY LA KET QUA: " & samplename, 4, "KIEM TRA DUNG MAU CAN NHAP?")
If result = vbNo Then
MsgBox ("Chon lai")
Call get_result
End If
End Sub

You might also like