• 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.

VBA for creating a form

tazz

Member
Hello!


I have one sheet(say SH1)with data in A1:C2.

I want to create a form in VB with 2 Labels(L1 & L2) and 4 Text Boxes(TB1 to TB4).

What I would like to accomplish is to have L1 showing data from cell A1 and L2 from A2.

Also I want TB1 to show data from B1, TB2 from B2, TB3 from C1, TB4 from C2 and also to be able to update cells B1:c2 writing in one or more TB.

I was able to create simple forms in VB to insert data but this one is above my actual level of VBA.


Thank you for your help.
 
Tazz


In the Form's Initialise Code you will need to add


Code:
Textbox1.value = Worksheets("Sh1").Range("B2").value


etc
 
Thank you Hui,

It worked really nice.

I tried the same thing for a label but is not working.

Any suggestions for a code that will update the cells in "sh1" with the new info from textboxes ?
 
Hi, tazz!


Each control has it own properties, for a label you should use:

-----

Label1.Caption = ...

-----


And for updating cells from text boxes data, add a command button and in its click event of the text box try this:

-----

Private Sub CommandButton1_Click()

Worksheets("Sh1").Range("B2").value = TextBox1.Value

Worksheets("Sh1").Range("C2").value = TextBox2.Value

End Sub

-----


Regards!
 
Thank you SirJB

Everything is working as I want.

One more question: how to call a Frame, a combo box and and check box.
 
Hi, tazz!

What do you mean by "calling a frame"? A frame is just that, something like a place holder.

And for combo box:

ComboBox1.List(ComboBox1.ListIndex)

And for check box:

CheckBox1.Value

Regards!
 
Back
Top