The short answer to your question is:
Private Sub CommandButton1_Click()
Dim WB1 As Workbook
Dim WB2 As Workbook
Dim LastRow As Long
Set WB1 = ActiveWorkbook
Set WB2 = Workbooks.Open(WB1.Path & "\RawData.xlsm")
With WB1.Sheets("CR Details")
'Find the last cell's row with data in any column
'(You can also use ".Cells(Rows.Count, 1).End(xlUp).row")
LastRow = .Range("A:AW").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row
'Copy the values
WB2.Sheets("sheet1").Range("A1", "AW" & LastRow) = .Range("A1", "AW" & LastRow).Value
End With
WB2.Close
End Sub
A more detailed explanation:
A very common code snippet to find the last used row is to use:
(will use column A to look for last used row)
Dim LastRow as Long
With ThisWorkbook.Sheets("CR Details")
LastRow = .Cells(Rows.Count, 1).End(xlUp).row
End With
Change "1" to the column number you want to look in.
To find the row of the last used cell in any column in the range("A:AW")
, then you would need something like this:
Dim LastRow as Long
With ThisWorkbook.Sheets("CR Details").Range("A:AW")
LastRow = .Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row
End With
That's it. Ron de Buin has a great page explaining this. The answers can also be found on Stack Overflow.