inwonderland7
New Member
- Joined
- Oct 11, 2023
- Messages
- 1
- Office Version
- 365
- Platform
- Windows
Hello,
I have 2 worksheets: Master Sheet and Sheet2
I would like the data in columns O-X from Master Sheet to copy over to Sheet2 cells C20-25 & E20-25.
Basically, if the column has value then enter into C20 but if not, skip the column and enter in the next column value to C20.
If C20 is filled then fill in cell C21 with the next column data.
And so on.
Here are some screenshots to help visualize.
Any help is greatly appreciated!
EDIT:
Here is my current code for the other form cells if it helps.
Module1
Module2
I have 2 worksheets: Master Sheet and Sheet2
I would like the data in columns O-X from Master Sheet to copy over to Sheet2 cells C20-25 & E20-25.
Basically, if the column has value then enter into C20 but if not, skip the column and enter in the next column value to C20.
If C20 is filled then fill in cell C21 with the next column data.
And so on.
Here are some screenshots to help visualize.
Any help is greatly appreciated!
EDIT:
Here is my current code for the other form cells if it helps.
Module1
VBA Code:
Sub PopulateSheets()
Dim i As Integer
Dim ws As Worksheet
Dim row_num As Integer
Dim lastSheet As Integer
row_num = 3 ' starting row number on Master Sheet sheet
lastSheet = Worksheets("ACF Set Up").Range("B5").Value + 2 ' get last sheet number from ACF Set Up sheet
For i = 3 To lastSheet
Set ws = Worksheets(i)
If Worksheets("Master Sheet").Cells(row_num, 1).Value = "" Then ' skip the row if column A is blank
row_num = row_num + 1
i = i - 1 ' decrement the counter so we repeat the same sheet
Else ' populate the sheet if column A is not blank
ws.Range("C6").Value = Worksheets("Master Sheet").Cells(row_num, 1).Value
ws.Range("F5").Value = Worksheets("Master Sheet").Cells(row_num, 3).Value
ws.Range("F6").Value = Worksheets("Master Sheet").Cells(row_num, 14).Value
ws.Range("C12").Value = Worksheets("Master Sheet").Cells(row_num, 11).Value
If Worksheets("Master Sheet").Cells(row_num, 7).Value = "" Then
ws.Range("D10").Value = Worksheets("Master Sheet").Cells(row_num, 9).Value
Else
ws.Range("D10").Value = "N/A"
End If
If Worksheets("Master Sheet").Cells(row_num, 7).Value = "" Then
ws.Range("F10").Value = Worksheets("Master Sheet").Cells(row_num, 10).Value
Else
ws.Range("F10").Value = "N/A"
End If
If Worksheets("Master Sheet").Cells(row_num, 7).Value = "" Then
ws.Range("D9").Value = "N/A"
Else
ws.Range("D9").Value = Worksheets("Master Sheet").Cells(row_num, 7).Value
End If
If Worksheets("Master Sheet").Cells(row_num, 7).Value = "" Then
ws.Range("F9").Value = "N/A"
Else
ws.Range("F9").Value = Worksheets("Master Sheet").Cells(row_num, 8).Value
End If
If Worksheets("Master Sheet").Cells(row_num, 5).Value = "" Then
ws.Range("D14").Value = ""
Else
ws.Range("D14").Value = Worksheets("Master Sheet").Cells(row_num, 5).Value
End If
If Worksheets("Master Sheet").Cells(row_num, 6).Value = "" Then
ws.Range("F14").Value = ""
Else
ws.Range("F14").Value = Worksheets("Master Sheet").Cells(row_num, 6).Value
End If
If Worksheets("Master Sheet").Cells(row_num, 4).Value = "" Then
ws.Range("D15").Value = ""
Else
ws.Range("D15").Value = Worksheets("Master Sheet").Cells(row_num, 3).Value
End If
If Worksheets("Master Sheet").Cells(row_num, 4).Value = "" Then
ws.Range("F15").Value = ""
Else
ws.Range("F15").Value = Worksheets("Master Sheet").Cells(row_num, 4).Value
End If
If Worksheets("Master Sheet").Cells(row_num, 12).Value = "" Then
ws.Range("D16").Value = ""
Else
ws.Range("D16").Value = Worksheets("Master Sheet").Cells(row_num, 12).Value
End If
If Worksheets("Master Sheet").Cells(row_num, 8).Value = "" Then
ws.Range("A9").Value = ""
Else
ws.Range("A9").Value = "X"
End If
If Worksheets("Master Sheet").Cells(row_num, 10).Value = "" Then
ws.Range("A10").Value = ""
Else
ws.Range("A10").Value = "X"
End If
If Worksheets("Master Sheet").Cells(row_num, 11).Value = "" Then
ws.Range("A12").Value = ""
Else
ws.Range("A12").Value = "X"
End If
If Worksheets("Master Sheet").Cells(row_num, 6).Value = "" Then
ws.Range("A14").Value = ""
Else
ws.Range("A14").Value = "X"
End If
If Worksheets("Master Sheet").Cells(row_num, 4).Value = "" Then
ws.Range("A15").Value = ""
Else
ws.Range("A15").Value = "X"
End If
row_num = row_num + 1 ' increment row number for the next sheet
End If
Next i
End Sub
Module2
VBA Code:
Sub DuplicateSheets()
Dim i As Integer
Dim newSheet As Worksheet
Dim numSheets As Integer
numSheets = Worksheets("ACF Set Up").Range("B19").Value
For i = 3 To numSheets + 2 ' start at sheet 3 and create numSheets sheets
Sheets("Sheet2").Copy after:=Sheets(Sheets.Count)
Set newSheet = ActiveSheet
newSheet.Name = "Sheet" & i
Next i
End Sub
Attachments
Last edited by a moderator: