The following code pastes values begining from the last available space in column F. Is…
- User
The following code pastes values begining from the last available space in column F. Is it possible to find the last available space, skip a row, add the words "Last Twenty Jobs" then paste the values found: Sub LastTenJobs()
Dim wscf As Worksheet Dim wsjr As Worksheet Dim lastRow As Long Dim copyRange As Range Dim cell As Range
Set wscf = Sheets(Range("G3").Value) Set wsjr = Sheets("Start Page")
Application.ScreenUpdating = True Application.EnableEvents = True Range("F5:F8").Calculate ActiveSheet.Range("F9:F60").ClearContents Application.Wait (Now + TimeValue("0:00:01")) ActiveSheet.Range("G3").Formula = ActiveSheet.Range("G3").Formula Application.Wait (Now + TimeValue("0:00:01")) ActiveSheet.Range("H3").Formula = ActiveSheet.Range("H3").Formula
If ActiveSheet.Range("G3") = "" Or 0 Then Application.ScreenUpdating = True Application.EnableEvents = True Exit Sub End If Dim LastRowJ As Long Dim lastRowF As Long Dim i As Long
Set wscf = Sheets(Range("G3").Value) Set wsjr = Sheets("Start Page")
LastRowJ = wscf.Cells(wscf.Rows.count, 10).End(xlUp).Row
If LastRowJ < 5 Then Exit Sub End If
lastRowF = wsjr.Cells(Rows.count, "F").End(xlUp).Row + 1
For i = LastRowJ To 1 Step -1 If wscf.Cells(i, 10).Value <> vbNullString Then wsjr.Cells(lastRowF, 6).Value = wscf.Cells(i, 10).Value lastRowF = lastRowF + 1 End If Next i
Application.ScreenUpdating = True Application.EnableEvents = True
End Sub
- Assistant
Yes, it is possible to add those words and skip a row before pasting the values. Here is the modified code:
Sub LastTenJobs()
Dim wscf As Worksheet Dim wsjr As Worksheet Dim lastRow As Long Dim copyRange As Range Dim cell As Range
Set wscf = Sheets(Range("G3").Value) Set wsjr = Sheets("Start Page")
Application.ScreenUpdating = True Application.EnableEvents = True Range("F5:F8").Calculate ActiveSheet.Range("F9:F60").ClearContents Application.Wait (Now + TimeValue("0:00:01")) ActiveSheet.Range("G3").Formula = ActiveSheet.Range("G3").Formula Application.Wait (Now + TimeValue("0:00:01")) ActiveSheet.Range("H3").Formula = ActiveSheet.Range("H3").Formula
If ActiveSheet.Range("G3") = "" Or 0 Then Application.ScreenUpdating = True Application.EnableEvents = True Exit Sub End If
Dim LastRowJ As Long Dim lastRowF As Long
Set wscf = Sheets(Range("G3").Value) Set wsjr = Sheets("Start Page")