Hey all,
I'm having difficulty with some basic syntax. I have the code below to find the last row, and then just below that, the code that I am using to try and select everything from A2:U2 down to the lastrow. Help? any ideas?
I'm having difficulty with some basic syntax. I have the code below to find the last row, and then just below that, the code that I am using to try and select everything from A2:U2 down to the lastrow. Help? any ideas?
Code:
Function xlLastRow(Optional WorksheetName As String) As Long
' find the last populated row in a worksheet
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
Sub NEW_WORKSHEET()
'
'This is the sheet witht the pull of information from a database that can
' have a varying number of rows
Sheets("Sheet1").Select
Range("A1", "U1").Select
ActiveSheet.Range(Selection, x1lastrow).Select
Selection.Copy
Sheets.Add.Name = "Master Source"
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub