Hi,
i have the following code that work great for one row of data (copy/paste/transpose) but I am trying to tweak it because I know have multiple rows Of data per employee and don't need to transpose it just paste it. What I need to do is lookup the value in the master for the tab name and find all the rows that match then copy and paste all of them that into the individual named tab that matches starting at s2.
Sub populateSheets()
Set empSheet = Sheets("Employee Sheet")
lr = empSheet.Range("A" & Rows.Count).End(xlUp).Row
For each c In empSheet.Range("A1:A" & lr)
If wsExists(c.Text) then
empSheet.Range("A" & c.Row &":CU" & c.Row).Copy
Sheets(c.Text).Range("G2").PasteSpecial Transpose:=True
else
MsgBox "Worksheet " & c.Text & " not found
End If
Next
End Sub
Function wsExists(ByVal sName As String) As Boolean
wsExists = False
For each ws In Worksheets
If sName = ws.Name Then
wsExists = True
Exit Function
End if
Next ws
End Function
i have the following code that work great for one row of data (copy/paste/transpose) but I am trying to tweak it because I know have multiple rows Of data per employee and don't need to transpose it just paste it. What I need to do is lookup the value in the master for the tab name and find all the rows that match then copy and paste all of them that into the individual named tab that matches starting at s2.
Sub populateSheets()
Set empSheet = Sheets("Employee Sheet")
lr = empSheet.Range("A" & Rows.Count).End(xlUp).Row
For each c In empSheet.Range("A1:A" & lr)
If wsExists(c.Text) then
empSheet.Range("A" & c.Row &":CU" & c.Row).Copy
Sheets(c.Text).Range("G2").PasteSpecial Transpose:=True
else
MsgBox "Worksheet " & c.Text & " not found
End If
Next
End Sub
Function wsExists(ByVal sName As String) As Boolean
wsExists = False
For each ws In Worksheets
If sName = ws.Name Then
wsExists = True
Exit Function
End if
Next ws
End Function