LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default UserForm/If Help

I have tried many ways to figure this out, with no success. I have a monthly
data sheet with data that needs to be entered for 6 days a week. This is
currently done by arrowing across the cells, entering the data by date, day,
and name and I'd like to make this much easier by using a UserForm. The
spreadsheet I'm using now is set up for 5-weeks so I can just enter a date in
the Monday field of the first week and the date populates from there. The
name fields all link back to an employee list of 55 possible people.

There are 6 pieces of data needed and they need to be separated by date and
name. The date and name fields are in ComboBoxes with drop down lists. I can
put the data in the sheet and have it populate blank lines, and I had thought
about setting up a vlookup in the daily sheets by just setting up tables and
populating those from the UserForm. The problem is the number of employees in
the sheet can vary daily from 40+, so I can't tell for certain where the data
will end each day and I haven't found a way to fill the table each day to 55
lines. My latest attempt uses If statements in VBA that would go to a sub
named by day (I've called them Daily1, Daily2, etc) based on the value in the
date ComboBox.

I have no experience with goto's (actually only a little with VBA at all
except for Macro's). Would that be better? I've pasted part of the code below,
and I would appreciate any assistance or advice.

I'm only pasting part of this, since I think it will get the idea across
without going on forever. What I tried to do was put an If statement that
referred to the 30 tables (when created anyway).The code I've made for the
submit button is first, then the "Daily" tables. I REALLY appreciate any help
anyone can give. I've been trying for some time now.

Private Sub SubmitButton_Click()
' Make sure data sheet is active
Sheets("Daily").Activate

' Determine the next empty row
NextRow = Application.WorksheetFunction.CountA(Range("AA:AA" )) + 6

' Find the Date and make sure all data is entered
If ComboBox2.Text = A4 Then Daily1
If ComboBox2.Text = A66 Then Daily2
If ComboBox2.Text = A128 Then Daily3
If ComboBox2.Text = A190 Then Daily4
If ComboBox2.Text = A252 Then Daily5

Etc, etc.

End Sub

Sub Daily1()
Cells(NextRow, 78) = ComboBox1.Text
If ComboBox1.Text = "" Then
MsgBox "You must enter a name."
ComboBox1.SetFocus
Exit Sub
End If
Application.Run Sub_SubmitButton
Cells(NextRow, 79) = ComboBox2.Text
If ComboBox2.Text = "" Then
MsgBox "You must enter a date."
ComboBox2.SetFocus
Exit Sub
End If
Application.Run Sub_SubmitButton
Cells(NextRow, 80) = TextBox1.Text
If TextBox1.Text = "" Then
MsgBox "You must enter Credited Hours."
TextBox1.SetFocus
Exit Sub
End If
Application.Run Sub_SubmitButton
Cells(NextRow, 81) = TextBox2.Text
If TextBox2.Text = "" Then
MsgBox "You must enter Total Hours."
TextBox2.SetFocus
End If
Application.Run Sub_SubmitButton
Cells(NextRow, 82) = TextBox3.Text
If TextBox3.Text = "" Then
MsgBox "You must enter Total Items."
TextBox3.SetFocus
End If
Application.Run Sub_SubmitButton
Cells(NextRow, 83) = TextBox4.Text
If TextBox4.Text = "" Then
MsgBox "You must enter Non-Amounts."
TextBox4.SetFocus
End If
Application.Run Sub_SubmitButton
Cells(NextRow, 84) = TextBox5.Text
If TextBox5.Text = "" Then
MsgBox "You must enter Internal Errors."
TextBox5.SetFocus
End If
Application.Run Sub_SubmitButton
Cells(NextRow, 85) = TextBox6.Text
If TextBox6.Text = "" Then
MsgBox "You must enter External Errors."
TextBox6.SetFocus
End If
Application.Run Sub_SubmitButton
End Sub

Sub Daily2()
Cells(NextRow, 86) = ComboBox1.Text
If ComboBox1.Text = "" Then
MsgBox "You must enter a name."
ComboBox1.SetFocus
Exit Sub
End If
Application.Run Sub_SubmitButton
Cells(NextRow, 87) = ComboBox2.Text
If ComboBox2.Text = "" Then
MsgBox "You must enter a date."
ComboBox2.SetFocus
Exit Sub
End If
Application.Run Sub_SubmitButton
Cells(NextRow, 88) = TextBox1.Text

Etc. Etc.

End Sub

--
Message posted via http://www.officekb.com
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Activating userform and filling it with data form row where userform is activate Marthijn Beusekom via OfficeKB.com[_2_] Excel Programming 3 May 6th 05 05:44 PM
Access from add_in userform to main template userform.... Ajit Excel Programming 1 November 18th 04 05:15 PM
Linking userform to userform in Excel 2003 missmelis01 Excel Programming 2 August 27th 04 08:07 PM
Userform inside another userform Ryan Excel Programming 0 April 23rd 04 08:01 PM
Userform Help Pete[_13_] Excel Programming 1 November 14th 03 10:03 PM


All times are GMT +1. The time now is 06:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"