A
Arran
Hi,
I am really hoping that someone can help me with the following as I am
struggling:
I have a spreadsheet that I have created a button in; what I would like to
happen is that when the button is clicked it allows the user to browse and
select a file, then from the selected file I would like it to copy certain
cells and insert them in to the spreadsheet with the button on to the next
available row (not allowing a duplicate to be copied).
This is what I have come up with but it doesn't work:
Sub importdata()
Dim sfilename As String
sfilename = Application.GetOpenFilename
If sfilename <> "False" Then Workbooks.Open sfilename
Exit Sub
Dim A As Integer, ML As Integer
ML = 4 'MasterList Start Row
Dim bk As Workbook
Set bk = Worksheets("sfilename")
With bk.Worksheets("New Contract Set Up Form")
Do Until ThisWorkbook.Sheets("Data Base").Cells(ML, 3) = ""
If ThisWorkbook.Sheets("Data Base").Cells(ML, 3) = bk.Worksheets("New
Contract Set Up Form").Cells(7, 4) Then
bk.Worksheets("New Contract Set Up Form").Activate
Sheets("New Contract Set Up Form").Cells(4, 7).Copy _
ThisWorkbook.Sheets("Data Base").Cells(ML, 2)
ML = 5
Exit Do
End If
ML = ML + 1
If ThisWorkbook.Sheets("Data Base").Cells(ML, 3) = "" Then
bk.Worksheets("New Contract Set Up Form").Activate
Sheets("New Contract Set Up Form").Cells(4, 7).Copy _
ThisWorkbook.Sheets("Data Base").Cells(ML, 2)
End If
Loop
End Sub
Any help will be greatly appreciated
I am really hoping that someone can help me with the following as I am
struggling:
I have a spreadsheet that I have created a button in; what I would like to
happen is that when the button is clicked it allows the user to browse and
select a file, then from the selected file I would like it to copy certain
cells and insert them in to the spreadsheet with the button on to the next
available row (not allowing a duplicate to be copied).
This is what I have come up with but it doesn't work:
Sub importdata()
Dim sfilename As String
sfilename = Application.GetOpenFilename
If sfilename <> "False" Then Workbooks.Open sfilename
Exit Sub
Dim A As Integer, ML As Integer
ML = 4 'MasterList Start Row
Dim bk As Workbook
Set bk = Worksheets("sfilename")
With bk.Worksheets("New Contract Set Up Form")
Do Until ThisWorkbook.Sheets("Data Base").Cells(ML, 3) = ""
If ThisWorkbook.Sheets("Data Base").Cells(ML, 3) = bk.Worksheets("New
Contract Set Up Form").Cells(7, 4) Then
bk.Worksheets("New Contract Set Up Form").Activate
Sheets("New Contract Set Up Form").Cells(4, 7).Copy _
ThisWorkbook.Sheets("Data Base").Cells(ML, 2)
ML = 5
Exit Do
End If
ML = ML + 1
If ThisWorkbook.Sheets("Data Base").Cells(ML, 3) = "" Then
bk.Worksheets("New Contract Set Up Form").Activate
Sheets("New Contract Set Up Form").Cells(4, 7).Copy _
ThisWorkbook.Sheets("Data Base").Cells(ML, 2)
End If
Loop
End Sub
Any help will be greatly appreciated