External dada copy errors'

Ks1102

Well-known Member
Joined
Jan 8, 2008
Messages
689
Hi, please help to see wahat's the code as below which wrong as color RED, the intents is want to get data base on the acitive sheet to paste base on Rrows count from cloumn "B"

Sub testing()
Dim home As Worksheet
Dim Filename As String
Dim Wb As Workbook

With Application.FileDialog(msoFileDialogOpen)

.AllowMultiSelect = False
If .Show = -1 Then

Filename = .SelectedItems(1)
Set home = ActiveWorkbook.ActiveSheet
Range("B1").Select
Set Wb = Workbooks.Open(Filename)
Wb.Worksheets("MAN_SUM").Range("K6:K7").Copy
home("Sheet1").Cells(Rows.Count, "B").End(x1up).Offset(1).Paste Wb.Close (False)
End If
End With
End Sub



your help I highly appreciate
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
should be
Rich (BB code):
home.Cells(Rows.Count, "B").End(xlup).Offset(1).PasteSpecial
Wb.Close (False)
However, you don't need to open
Rich (BB code):
Sub test()
Dim home As Worksheet
Dim Filename As String, myDir As String, fn As String
Set home = ThisWorkbook.ActiveSheet
With Application.FileDialog(msoFileDialogOpen)
    .AllowMultiSelect = False
    If .Show = -1 Then
        Filename = .SelectedItems(1)
        myDir = Left$(Filename, InStrRev(Filename, "\"))
        fn = Mid$(Filename, InStrRev(Filename,"\")+1)
        With home.Cells(Rows.Count, "b").End(xlUp)(2).Resize(2)
            .Formula = "='" & myDir & "[" & fn & "]MAN_SUM'!k6"
            .Value = .Value
        End With
    End If
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,864
Messages
6,121,986
Members
449,058
Latest member
oculus

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top