Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() In the following code I have my been able to complete the following task: my userform will - add the name entered on it to the selected cells in the activate worksheet (A). - add the name entered into the userform to the title of a new worksheet (B) tab - and it will copy the contents of another worksheet to the worksheet (B) This is great I am so close to completing my goal. Now, I need to have: - the name of the worksheet (B) added to a cell in worksheet (B) - and I want to be able to have the contents of the entire row created in worksheet (A) that shares the name of worksheet (B) be copied over to certain cells in worksheet (B) as they are added to worksheet (A). So for example: If I enter John Brown into my userform it will create a row entry in worksheet (A) that says John Brown and it will create worksheet (B) that has the title John Brown and I want to have the name John Brown appear in cell A1 in worksheet (B), then I want to be able to add data to worksheet (A) and have that data fill-in and create cell info from worksheet (A) to worksheet (B) of the same name. current code Code: -------------------- Private Sub cmdAdd_Click() Dim iRow As Long Dim ws As Worksheet Dim newSheetName As String Set ws = Worksheets("Class GradeSheet") 'find first empty row in database iRow = ws.Cells(Rows.Count, 1) _ .End(xlUp).Offset(1, 0).Row 'check for a part number If Trim(Me.TextBox56.Value) = "" Then Me.TextBox56.SetFocus MsgBox "Please enter last name" Exit Sub End If 'copy the data to the database ws.Cells(iRow, 1).Value = Me.TextBox56.Value ws.Cells(iRow, 2).Value = Me.TextBox55.Value newSheetName = ws.Cells(iRow, 1) & "," & ws.Cells(iRow, 2) 'clear the data Me.TextBox56.Value = "" Me.TextBox55.Value = "" Me.TextBox56.SetFocus For Each ws In Worksheets If ws.Name = newSheetName Or _ newSheetName = "" Or _ IsNumeric(newSheetName) Then MsgBox "Sheet already exists or name is invalid", vbInformation Exit Sub End If Next Sheets("Student Sheet").Copy befo=Sheets(1) Sheets(1).Name = newSheetName Sheets(newSheetName).Move After:=Sheets(Sheets.Count) 'close userform Unload Me End Sub -------------------- -- oberon.black ------------------------------------------------------------------------ oberon.black's Profile: http://www.excelforum.com/member.php...o&userid=26732 View this thread: http://www.excelforum.com/showthread...hreadid=401531 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Which bit doesn't work? It's very complicated to follow. Maybe give a indication of what you can't get to work -- gearo ----------------------------------------------------------------------- gearoi's Profile: http://www.excelforum.com/member.php...fo&userid=2657 View this thread: http://www.excelforum.com/showthread.php?threadid=40153 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
complex color fill conditions- if statements or complex formula? | Excel Discussion (Misc queries) | |||
complex index function not working | Excel Worksheet Functions | |||
Code not working | Excel Programming | |||
Do---Loop Error in Complex Code | Excel Programming | |||
For Each Code Not Working | Excel Programming |