I know there are several threads about this but I couldn't find one to work for me so here goes. Below is the code I created using the Record Macro tool to save all the selected data from one sheet to another but I cannot figure out how to copy/paste new data below the existing data and not over it. I have used the code in red below on other spreadsheets before and this has worked but on this new spreadsheet I'm copying 60 rows of data per run and I think that might be the problem...
Also, I wish to not copy/paste rows that have blank cells and was trying an If statement but couldn't make it work... Otherwise I just end up having to manually delete the rows with blank spaces in them.
What do you recommend?
Sub PCLitesHistorical()
'
' PCLitesHistorical Macro
'
Dim i As Integer
Dim Ans As String
Ans = MsgBox("Are you sure you want to save data?", vbYesNo, "Are you sure?")
If Ans = vbYes Then
Application.ScreenUpdating = False 'This keeps the screen the same while the code executes
Sheets("PCLites Historical").Select
Range("B2:K2").Select
i = 1
Do Until Range("B2").Offset(i, 0).Value = ""
i = i + 1
Loop
Sheets("SMP PCLites").Select
Range("D6:H25,D31:H50,D56:H75").Select
Selection.Copy
Sheets("PCLites Historical").Select
Range("B3").Select
ActiveSheet.Paste
Sheets("SMP PCLites").Select
Range("C4:L4").Select
Selection.Copy
Sheets("PCLites Historical").Select
Range("G3:G22").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("SMP PCLites").Select
Range("C29").Select
Selection.Copy
Sheets("PCLites Historical").Select
Range("G23:G42").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("SMP PCLites").Select
Range("C54").Select
Selection.Copy
Sheets("PCLites Historical").Select
Range("G43:G62").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("SMP PCLites").Select
Range("I6:L25,I31:L50,I56:L75").Select
Selection.Copy
Sheets("PCLites Historical").Select
Range("H3").Select
ActiveSheet.Paste
Range("B3").Select
Application.CutCopyMode = False
Sheets("SMP PCLites").Select
Range("D6").Select
Application.ScreenUpdating = True
ActiveWorkbook.Save
Ans = MsgBox("Data saved.", vbOKOnly, "Thanks.")
End If
End Sub
Appreciate the help in advance.
Thanks.
Also, I wish to not copy/paste rows that have blank cells and was trying an If statement but couldn't make it work... Otherwise I just end up having to manually delete the rows with blank spaces in them.
What do you recommend?
Sub PCLitesHistorical()
'
' PCLitesHistorical Macro
'
Dim i As Integer
Dim Ans As String
Ans = MsgBox("Are you sure you want to save data?", vbYesNo, "Are you sure?")
If Ans = vbYes Then
Application.ScreenUpdating = False 'This keeps the screen the same while the code executes
Sheets("PCLites Historical").Select
Range("B2:K2").Select
i = 1
Do Until Range("B2").Offset(i, 0).Value = ""
i = i + 1
Loop
Sheets("SMP PCLites").Select
Range("D6:H25,D31:H50,D56:H75").Select
Selection.Copy
Sheets("PCLites Historical").Select
Range("B3").Select
ActiveSheet.Paste
Sheets("SMP PCLites").Select
Range("C4:L4").Select
Selection.Copy
Sheets("PCLites Historical").Select
Range("G3:G22").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("SMP PCLites").Select
Range("C29").Select
Selection.Copy
Sheets("PCLites Historical").Select
Range("G23:G42").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("SMP PCLites").Select
Range("C54").Select
Selection.Copy
Sheets("PCLites Historical").Select
Range("G43:G62").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("SMP PCLites").Select
Range("I6:L25,I31:L50,I56:L75").Select
Selection.Copy
Sheets("PCLites Historical").Select
Range("H3").Select
ActiveSheet.Paste
Range("B3").Select
Application.CutCopyMode = False
Sheets("SMP PCLites").Select
Range("D6").Select
Application.ScreenUpdating = True
ActiveWorkbook.Save
Ans = MsgBox("Data saved.", vbOKOnly, "Thanks.")
End If
End Sub
Appreciate the help in advance.
Thanks.