VBA Insert Into Specific Cell

Joined
Apr 20, 2012
Messages
1
Reaction score
0
Hi there,

It's my first attempt at VBA programming and I'm having some difficulty. I have a UserForm with three inputs (Name, Training Name, Level), which are all working fine, but when I come to output the form onto the spreadsheet, I can't get it to go into the right cell.

'Name' is in the first column of the spreadsheet, 'Training Name' is in the fourth row, and I want the form to check the name inputted against the spreadsheet, and find the row it's on, and check the training name to find the column it's in, inserting 'level' into that cell.

Here's what I have so far:

Code:
Private Sub cmdAdd_Click()
Dim RowID As Range
Dim ColumnID As Range
Dim ws As Worksheet
Set ws = Worksheets("Master")

'check for a name
If Trim(Me.cboName.Value) = "" Then
  Me.cboName.SetFocus
  MsgBox "Please enter an employee's name"
  Exit Sub
End If

'check for a training name
If Trim(Me.cboTraining.Value) = "" Then
  Me.cboTraining.SetFocus
  MsgBox "Please enter the training being recorded."
  Exit Sub
End If

'check for a level number
If Trim(Me.cboLevel.Value) = "" Then
  Me.cboLevel.SetFocus
  MsgBox "Please enter the level of training being recorded"
  Exit Sub
End If


'copy the data to the database
With ws
  .Cells(RowID, ColumnID).Value = Me.cboLevel.Value
End With

'clear the data
Me.cboTraining.Value = ""
Me.cboLevel.Value = ""
Me.cboName.SetFocus

So I guess my question is: How can I find/define the RowID and ColumnID values?

Any help appreciated!
 

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