Problem with Userform

V

vitorjose

Thanks for the help - i created a userform, using a sample downloaded
from the internet, to populate 2 lists. This is the code

Option Explicit

Private Sub CmdAddInt_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Resources")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.NameInt.Value
ws.Cells(iRow, 2).Value = Me.CompInt.Value


'clear the data
Me.NameInt.Value = ""
Me.CompInt.Value = ""
'Me.NameInt.SetFocus

Unload Me

End Sub

This routine does not work - in come cases the entry form will not
display any text as i enter it and it will not copy the entered text
into the specified worksheet. The routine shown below appears to my
untrained eyes to be identical and it does exactly what i want it to
do. Can some one help me figure out why one works but not the other.
The are contained within a multipage userform. In addtion i am
interested in learning how to program within excel - i have
significant experience in using excel but no programming experience -
can someone suggest the best way to learn programming excel vba

Thanks for your help



Private Sub CmdAddEx_Click()
Dim eRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Resources Ext")

'find first empty row in database
eRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'copy the data to the database
ws.Cells(eRow, 1).Value = Me.NameExt.Value
ws.Cells(eRow, 2).Value = Me.CompExt.Value


'clear the data
Me.NameExt.Value = ""
Me.CompExt.Value = ""
Me.NameExt.SetFocus

Unload Me

End Sub
 
V

vitorjose

I have figured out my problem with the userform - i would still like
some advice on the best way to learn the excel vba programming

Thanks
 
J

JLGWhiz

The best way to learn how to program with VBA is to initiate a project.
Think of something that you do on a regular basis that could be done easier
if you had a database that only needed to be updated and summarized to
produce a product. Then take one bite of the elephant at a time. Organize
data, sort data, compare data, extract data and summarize data. Insert
message boxes for information or decision making. Insert inputboxes for user
participation. Create forms to control user options and avoid human error.

As you build each piece of your project, draw a diagram of what you are
doing and you can see that you are actually building a logical system. You
simply use the VBA code to execute the steps electronically, that you would
normally do manually.
Check this site for basic programming concepts:

http://www.excel-vba.com/excel-vba-contents.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top