Select and copy Rows

mdorey

Board Regular
Joined
Oct 6, 2011
Messages
64
hello all,

How can i select an unknown range of rows from the second until the second before last and then copy them?

Thanks
 
Last edited:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Rows("2:" & Range([A1], ActiveSheet.UsedRange).Rows.Count - 1).Copy
 
Last edited:
Upvote 0
Rows("2:" & Range([A1], ActiveSheet.UsedRange).Rows.Count - 1).Copy

I want to put that code in workbook1, workbook1 will open several workbooks (six) with vba.

How can i adapt that code to select the range from the other workbooks and past on workbook1.sheet(named with the name of the files open)?

Here is a sample of the code
Code:
Sub OpenData()


Dim myValue As Variant
myValue = InputBox("File name?")


    ChDir "L:\..."
    Workbooks.OpenText Filename:= _
        "L:\...\PRO " & myValue & ".txt" _
        , Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
        xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
        Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(1, 1), _
        TrailingMinusNumbers:=True
 
Last edited:
Upvote 0
Assuming column A on each sheet in Workbook1 can be used to find the next available blank row :

ActiveSheet.Rows("2:" & Range([A1], ActiveSheet.UsedRange).Rows.Count - 1).Copy _
Workbooks("Workbook1").Sheets(myValue).Cells(Rows.Count, "A").End(xlUp)(2).EntireRow
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,279
Members
452,630
Latest member
OdubiYouth

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