seanjon
New Member
- Joined
- Dec 23, 2017
- Messages
- 10
Howdy!
I have a workbook for my employee’s weekly performance. Iexport the data from another program, copy it to one sheet (“WEEKLY NC”) and copystuff to another sheet (“WEEKLY BA”). I then run a VBA that sorts through allthis data, picks each employee’s data from each sheet and places itstrategically on that employee’s personal sheet. I then print them out and wediscuss it.
What I would like to do is create a VBA that will add a newemployee to the existing VBAs that picks and pulls the information. Each weekof the month has its own VBA code, so adding a new member is a copy/paste/editpain in the you know what.
So, I was thinking I could create a userform that would popup with an “add employee” button which will create the employee’s sheet (I havethe tools to do this part) and then have it write that employee’s VBA code tothe existing strings I already have. I hope this makes sense.
(Note: this is only week 1 stuff, and only 1 employee’scode. There are 5 different instances (one for each week) of this for eachemployee.)
I want to copy this VBA, paste it in the correct place, andchange the name to the new employee’s name.
Thanks!
I have a workbook for my employee’s weekly performance. Iexport the data from another program, copy it to one sheet (“WEEKLY NC”) and copystuff to another sheet (“WEEKLY BA”). I then run a VBA that sorts through allthis data, picks each employee’s data from each sheet and places itstrategically on that employee’s personal sheet. I then print them out and wediscuss it.
What I would like to do is create a VBA that will add a newemployee to the existing VBAs that picks and pulls the information. Each weekof the month has its own VBA code, so adding a new member is a copy/paste/editpain in the you know what.
So, I was thinking I could create a userform that would popup with an “add employee” button which will create the employee’s sheet (I havethe tools to do this part) and then have it write that employee’s VBA code tothe existing strings I already have. I hope this makes sense.
- Can this be done? Can you write a VBA that willinsert VBA into an existing VBA?
- Does anyone know how to do it?
(Note: this is only week 1 stuff, and only 1 employee’scode. There are 5 different instances (one for each week) of this for eachemployee.)
Rich (BB code):
Rich (BB code):
Rich (BB code):
Rich (BB code):
Private Sub Week1NC_Click()
Application.ScreenUpdating = False
Call BOB_NC_1
Call BOB_BA_1
Sheets("MONTHLY TOTALS").Select
Application.ScreenUpdating = True
End Sub
Private Sub BOB_NC_1()
Dim shSource As Worksheet
Dim shDestination As Worksheet
Set shSource = Sheets("WEEKLY NC")
Set shDestination = Sheets("BOB")
shSource.UsedRange.AutoFilter Field:=13, Criteria1:="*BOB*"
shSource.UsedRange.Columns("G:K").Offset(1).Copy
shDestination.Range("AA" & Rows.Count).End(xlUp).Offset(1).PasteSpecialxlPasteValues
Application.CutCopyMode = False
shSource.AutoFilterMode = False
Application.Goto shDestination.Range("A1")
End Sub
Private Sub BOB_BA_1()
Dim shSource As Worksheet
Dim shDestination As Worksheet
Set shSource = Sheets("WEEKLY BA")
Set shDestination = Sheets("BOB")
shSource.UsedRange.AutoFilter Field:=2, Criteria1:="*BOB*"
shSource.UsedRange.Columns("C:H").Offset(1).Copy
shDestination.Range("AH" &Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValues
Application.CutCopyMode = False
shSource.AutoFilterMode = False
Application.Goto shDestination.Range("A1")
End Sub
I want to copy this VBA, paste it in the correct place, andchange the name to the new employee’s name.
Thanks!