Hello, I am new to VBA and my knowledge is limited. I will try my best to provide an accurate description, but if additional clarification is needed please reach out. I am trying to create a VBA to accomplish the following:
- I need to replicate a Master worksheet based on the number of rows from an Import worksheet
- I also need to fill in the cells in the created worksheets with the associated data pulled in from the Import worksheet row
- I believe I need some sort of loop to pull in data from each row from the Import worksheet until I reach the end of the worksheet
- Identified rows from the Import worksheet I need to copy are (keep in mind, I need to start from row 2 then proceed until there are no more rows with data):
- A, B, O, Q, Y, BG, BW, CB, CC, CD, CE, CH, CJ
- Identified rows I need to paste in the newly created worksheets are (the rows will always be the same, but the worksheet will always be new):
- B7:C8, E7:F8, I7:J8, C14:E14, C15:E15, C16:E16, H14:J14, H16:J16, E20:J21, E22:J22, E23:J23, A27:J33, A37:J43
- This may be overkill, but is there some kind of check I can run to ensure duplicates do not occur?
VBA Code:
Sub makeTPRs()
' Declare variables sh1, sh2, c
Dim sh1 As Worksheet
Dim sh2 As Worksheet
Dim c As Range
' Set sh1 to TPR_Master worksheet
Set sh1 = Sheets("TPR_Master")
' Set sh2 to Jira_Import worksheet
Set sh2 = Sheets("Jira_Import")
' Count each number of filled rows in column 2, for every row counted create a new worksheet
' based on the TPR_Master worksheet and give the tab the associated TPR value
For Each c In sh2.Range("B2", sh2.Cells(Rows.Count, 2).End(xlUp))
sh1.Copy Before:=sh1
ActiveSheet.Name = c.Value
Next
End Sub