• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Combo-box values NOT transferring

Hello again,

I have the below code, which is supposed to take input provided from the user in ComboBox1 'RC_Numbers', ComboBox2 'RC_Name' and Textbox 'Expense' and put them starting in Row 2 in Columns 27, 28 & 29.

It put things in the right place, but somehow 'RC_Name' goes into Columns 27 & 28??

ComboBox1 and ComboBox2 work so that you can pick from either and it populates the other

This programming is all in the Forms.

Any and all help is appreciated.

Code:
Private Sub CancelButton_Click()
    Unload Me
End Sub
Private Sub CommandButton1_Click()
    Dim lRow As Long
    Dim ws As Worksheet
    Set ws = Worksheets("Master")
    If BundleCount.Value > 1 Then
    lCol = lCol + BundleCount.Value + 1
    End If
    lRow = ws.Cells(Rows.Count, 27).End(xlUp).Offset(1, 26).Row
    With ws
        .Cells(lRow, 27).Value = Me.RC_Numbers.Value
        .Cells(lRow, 28).Value = Me.RC_Name.Value
        .Cells(lRow, 29).Value = Me.Expense.Value
    End With
    RC_Numbers.ListIndex = -1
    RC_Name.ListIndex = -1
    Expense.Object.Value = ""
End Sub
Private Sub CommandButton3_Click()
    RC_Numbers.ListIndex = -1
    RC_Name.ListIndex = -1
    Expense.Object.Value = ""
End Sub
Private Sub Label1_Click()
.HorizontalAlignment
End Sub
Private Sub NewBundle_Click()
    Dim lCol As Long
    lCol = 27
    BundleCount.Value = BundleCount.Value + 1
End Sub
Private Sub RC_Name_Change()
    If Len(RC_Name.Text) <> 0 Then
        RC_Numbers.Value = RC_Name.Text
    End If
End Sub
Private Sub RC_Numbers_Change()
    If Len(RC_Numbers.Value) > 0 Then
        RC_Name.Text = RC_Numbers.Value
    End If
End Sub
Private Sub SpinButton1_Change()
BundleCount.Value = SpinButton1.Value
End Sub
[CODE]
 
Put following right after "With ws" line and see what comes up.
Code:
Debug.Print lRow & ", " &  Me.RC_Numbers.Value & ", " & Me.RC_Name.Value & ", " & Me.Expense.Value
 
Thanks, but absolutely nothing came up at all? When I ran in Debug Mode to see what values it was getting It is still pulling up the RC_Names for both the RC_Numbers & RC_Names.
 
Last edited by a moderator:
You checked in immediate window in VBE?

I'd recommend uploading sample workbook that replicates your issue. Without it, hard to say what exactly is your issue.
 
Attached is a down and dirty version of what I need. When the Userform 'Receipts' opens it allows the User to either select a RC_Code (Employees Code) or a RC_Name (Employee Name) ((Either selecting Code OR name pre-populates the other)) and enter a dollar amount.
It is then supposed to put the RC_Code, RC_Name & Expense into Columns 27, 28, 29 respectively.

The issue is some where it is putting the RC_Name in both Columns 27 & 28.
 

Attachments

  • Demo.xlsm
    20 KB · Views: 3
Your issue is that you are setting RC_Number.Value using RC_Name.Text on RC_Name_Change.

You can change your code to something like below.
Code:
        .Cells(lRow, 27).Value = Me.RC_Numbers.Text
        .Cells(lRow, 28).Value = Me.RC_Name.Value
        .Cells(lRow, 29).Value = Me.Expense.Value
 
AH HA Chiro, you are indeed an Excel Ninja.

Thanks for your help, I'll likely be posting another issue later today !!:eek:
 
Last edited by a moderator:
Back
Top