Option Explicit
Dim MyRange As Range
Sub MoveIt()
Set MyRange = Range((Cells(xlFirstRow, xlFirstCol)), (Cells(xlLastRow, xlLastCol)))
MyRange.Copy Destination:=Sheets("Sheet2").Range("B4")
End Sub
Function xlFirstCol(Optional WorksheetName As String) As Long
If WorksheetName = vbNullString Then
WorksheetName = ActiveSheet.Name
End If
With Worksheets(WorksheetName)
xlFirstCol = .Cells.Find("*", .Cells(1), xlFormulas, _
xlWhole, xlByColumns, xlNext).Column
End With
End Function
Function xlFirstRow(Optional WorksheetName As String) As Long
If WorksheetName = vbNullString Then
WorksheetName = ActiveSheet.Name
End If
With Worksheets(WorksheetName)
xlFirstRow = .Cells.Find("*", .Cells(1), xlFormulas, _
xlWhole, xlByRows, xlNext).Row
End With
End Function
Function xlLastRow(Optional WorksheetName As String) As Long
If WorksheetName = vbNullString Then
WorksheetName = ActiveSheet.Name
End If
With Worksheets(WorksheetName)
xlLastRow = .Cells.Find("*", .Cells(1), xlFormulas, _
xlWhole, xlByRows, xlPrevious).Row
End With
End Function
Function xlLastCol(Optional WorksheetName As String) As Long
If WorksheetName = vbNullString Then
WorksheetName = ActiveSheet.Name
End If
With Worksheets(WorksheetName)
xlLastCol = .Cells.Find("*", .Cells(1), xlFormulas, _
xlWhole, xlByColumns, xlPrevious).Column
End With
End Function
|