vb help - adding data to next available line

steve2115

Board Regular
Joined
Mar 17, 2014
Messages
82
I am in need of some help with a piece of vb code to add data to the next available blank row on an existing excel sheet named "MB51"

I need to browse for and then import data from an excel file (data is in columns A:N:) and then import all the data from that file into the first blank row on sheet MB51 , columns C:L

Here is code I currently have.

Code:
Sub Button1_Click()
Dim OpenFileName As String
 Dim wb As Workbook
 'Select and Open workbook
 OpenFileName = Application.GetOpenFilename("MB51,*.xlsx")
 If OpenFileName = "False" Then Exit Sub
 Set wb = Workbooks.Open(OpenFileName)
 'Get data EXAMPLE
 ThisWorkbook.Sheets("MB51").Range("C" & Rows.Count).End(xlUp).Row 1 = wb.Sheets(1).Range("A:N").Value

 MsgBox ("Import Complete")
wb.Close
    
    
End Sub
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,214,826
Messages
6,121,797
Members
449,048
Latest member
greyangel23

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