This is my current attempt at copying data from one tab and pasting into a table on a different tab. I began modifying the code below. The text highlighted in yellow is where I need help.
Essentially, here are the two scenarios:
ONE-
If F5 on the "Instructions" tabs = 1, then copy columns H:J starting at row 4 on sheet "Selected LP List" to the last three empty columns on the sheet "LPA Database Raw Data". NOTE: The range for the columns where the text should be copied into are F:EY and start at row 5
TWO-
If F5 on the "Instructions" tabs = 2, then copy columns H:J and L:N starting at row 4 on sheet "Selected LP List" to the last six empty columns on the sheet "LPA Database Raw Data". NOTE: The range for the columns where the text should be copied into are F:EY and start at row 5
This formula below worked well for me when I was copying data. It identified the last row, but I have re-organized my worksheets and now I am looking at the columns.
<style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; background-color: #ffffff; min-height: 13.0px}p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008f00; background-color: #ffffff}p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #011993; background-color: #ffffff}span.s1 {color: #011993}span.s2 {color: #000000}</style>
Public Sub PasteToLastRow()
Dim instructionsSheet As Worksheet
Dim databaseSheet As Worksheet
Dim lastRow As Long
Set instructionsSheet = Sheets("Instructions")
Set databaseSheet = Sheets("LPA Database Scores")
lastRow = databaseSheet.Range("C118").End(xlUp).Row + 1
If lastRow = 118 Then
' No more spare rows
Exit Sub
End If
' Copy the data
databaseSheet.Range("B56:AQ57" & CStr(5 + instructionsSheet.Range("F5").Value)).Copy
databaseSheet.Cells(lastRow, 2).PasteSpecial Paste:=xlPasteValues
End Sub
<style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; background-color: #ffffff; min-height: 13.0px}p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008f00; background-color: #ffffff}p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #011993; background-color: #ffffff}span.s1 {color: #011993}span.s2 {color: #000000}</style><style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff}span.s1 {color: #011993}</style>
Essentially, here are the two scenarios:
ONE-
If F5 on the "Instructions" tabs = 1, then copy columns H:J starting at row 4 on sheet "Selected LP List" to the last three empty columns on the sheet "LPA Database Raw Data". NOTE: The range for the columns where the text should be copied into are F:EY and start at row 5
TWO-
If F5 on the "Instructions" tabs = 2, then copy columns H:J and L:N starting at row 4 on sheet "Selected LP List" to the last six empty columns on the sheet "LPA Database Raw Data". NOTE: The range for the columns where the text should be copied into are F:EY and start at row 5
This formula below worked well for me when I was copying data. It identified the last row, but I have re-organized my worksheets and now I am looking at the columns.
<style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; background-color: #ffffff; min-height: 13.0px}p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008f00; background-color: #ffffff}p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #011993; background-color: #ffffff}span.s1 {color: #011993}span.s2 {color: #000000}</style>
Public Sub PasteToLastRow()
Dim instructionsSheet As Worksheet
Dim databaseSheet As Worksheet
Dim lastRow As Long
Set instructionsSheet = Sheets("Instructions")
Set databaseSheet = Sheets("LPA Database Scores")
lastRow = databaseSheet.Range("C118").End(xlUp).Row + 1
If lastRow = 118 Then
' No more spare rows
Exit Sub
End If
' Copy the data
databaseSheet.Range("B56:AQ57" & CStr(5 + instructionsSheet.Range("F5").Value)).Copy
databaseSheet.Cells(lastRow, 2).PasteSpecial Paste:=xlPasteValues
End Sub
<style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; background-color: #ffffff; min-height: 13.0px}p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008f00; background-color: #ffffff}p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #011993; background-color: #ffffff}span.s1 {color: #011993}span.s2 {color: #000000}</style><style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff}span.s1 {color: #011993}</style>