I am having a problem with selecting a range for some reason tonight. I have tried everything I know to do and nothing seems to be helping.
Here is all of the code
Sub FormatData()
Dim wsPell As Worksheet
Dim wsFormat As Worksheet
Dim lLastRow As Long
Dim lRow As Long
Dim lFormatRow As Long
Dim lPellAmt As Long
Dim sTemp As String
Set wsPell = Sheets(tabname)
Set wsFormat = Sheets("Formatted")
wsFormat.Cells.ClearContents
lLastRow = wsPell.Cells(Rows.Count, 1).End(xlUp).Row
lFormatRow = 1
For lRow = 2 To lLastRow Step 1
SSN = wsPell.Cells(lRow, 1).Value
Name = wsPell.Cells(lRow, 3).Value + ", " + wsPell.Cells(lRow, 4).Value + _
" " + wsPell.Cells(lRow, 5)
If TermSel = "All" Then
lPellAmt = wsPell.Cells(lRow, 6).Value + wsPell.Cells(lRow, 7).Value + _
wsPell.Cells(lRow, 8).Value
Else
lPellAmt = wsPell.Cells(lRow, column).Value
End If
If lPellAmt > 0 Then
wsFormat.Cells(lFormatRow, 1).Value = "DOE"
wsFormat.Cells(lFormatRow, 2).Value = SSN
wsFormat.Cells(lFormatRow, 3).Value = Name
wsFormat.Cells(lFormatRow, 4).Value = lPellAmt
lFormatRow = lFormatRow + 1
End If
lPellAmt = 0
Next lRow
wsFormat.Range(wsFormat.Cells(1, 1), wsFormat.Cells(lFormatRow - 1, 4)).Range.Select
Set wsPell = Nothing
Set wsFormat = Nothing
End Sub
This is the line that is giving me the problem (4th up from the bottom)
wsFormat.Range(wsFormat.Cells(1, 1), wsFormat.Cells(lFormatRow - 1, 4)).Range.Select
Everytime I run the code I get "Select method of Range Class failed"
This has got to be something simple. Maybe I am just tired and need to go home for the night!
Does anyone have any suggestions!
Bookmarks