I have a code that copies a specified range (depending on how many values cells in another sheet have values). so if in sheet 1 column B I have 4 cells populated, the macro will copy the values of 4 rows in sheet 2.
Now I would like it also to always copy another row in same sheet together with the range which is W157.
The part that copies the range is working fine but it's not copying the one last row.
any suggestions please.
Public Sub CommandButton2_Click()
Dim i As Long
Dim wb As Workbook
Dim NewWB As Workbook
Dim saveFile As String
Dim WorkRng As Range
On Error Resume Next
i = Sheets(1).Range("B14").End(xlDown).Row - 13 '(start checking if any
values from B15 downwards)
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set wb = ActiveWorkbook
Set NewWB = Application.Workbooks.Add
Thispath = wb.path
wb.Sheets(2).Range ("W7:W" & i + 5) & wb.Sheets(2).Range("W157").Copy
NewWB.Worksheets(1).Range("A1").PasteSpecial Paste:=xlPasteValues
NewWB.SaveAs filename:=Thispath & "\TEXTFILE.txt", FileFormat:=xlText,
CreateBackup:=False
NewWB.Close
Application.CutCopyMode = False
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub