Macro edit range to copy

mdorey

Board Regular
Joined
Oct 6, 2011
Messages
64
Hello everyone,

need your help to edit the following macro:

Code:
Sub x()
    Dim myValue As Variant
    myValue = InputBox("Give me some input")
        
    Dim rFind As Range, ws As Worksheet, wb1 As Workbook, wb2 As Workbook
    Dim RngCp As String
    RngCp = Rows("2:" & Range([A1], ActiveSheet.UsedRange).Rows.Count - 2).Select
    
    Set wb1 = ThisWorkbook 'containing macro
    Set wb2 = Workbooks.Open("L:\...\PRO " & myValue & ".txt") 'put details of file being opened
     
    Set rFind = wb1.Sheets("pro").Columns(2).Find(What:=wb2.Sheets("pro " & myValue").Range("B2"), _
    Lookat:=xlWhole, MatchCase:=False, SearchFormat:=False)
     
    If Not rFind Is Nothing Then
        rFind.EntireRow.Value = wb2.Sheets("pro " & myValue).Range("B2").EntireRow.Value
    End If
    
        'Windows("pro " & myValue & ".txt").Close
End Sub

this code is coping the B to the right place but i need that code to copy from row B until the third last one and past exactly where this code says to... can anyone edit the copy range please???

Many thanks
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,224,827
Messages
6,181,200
Members
453,022
Latest member
RobertV1609

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