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

Support on VBA code

Ramesha

Member
I'm new to VBA, I'm facing challenge in solving the following, thank you in advance

Code:
Private Sub Enter_Click()
row_number = 1
Do
DoEvents
row_number = row_number + 1
item_in_review = Sheets("Sheet1").Range("A2" & 2)
If item_in_review = TextBox1.Text Then
  TextBox1 = Sheets("Sheet1").Range("A2" & 2)
  TextBox2 = Sheets("Sheet1").Range("A2" & 2)
  TextBox3 = Sheets("Sheet1").Range("A2" & 2)
  TextBox4 = Sheets("Sheet1").Range("A2" & 2)
  TextBox5 = Sheets("Sheet1").Range("A2" & 2)
  TextBox6 = Sheets("Sheet1").Range("A2" & 2)
  TextBox7 = Sheets("Sheet1").Range("A2" & 2)
  TextBox8 = Sheets("Sheet1").Range("A2" & 2)
  TextBox9 = Sheets("Sheet1").Range("A2" & 2)
  TextBox10 = Sheets("Sheet1").Range("A2" & 2)
  TextBox11 = Sheets("Sheet1").Range("A2" & 2)
  TextBox12 = Sheets("Sheet1").Range("A2" & 2)
  End If

Loop Until item_in_review = Range("A2" & 10000)

End Sub
 
Last edited by a moderator:
Two questions

In English not VBA , Can you please explain what you are trying to achieve
What are you trying to say with Range("A2" & 2) ?
 
Can you please explain what you are trying to achieve ?

Does Range("A2" & 2) mean offset two rows down from A2?
That is done using Range("A2").Offset(2,)

But all the textboxes will have the same value ?
 
I've created the form as below, once the text fields are entered, on pressing "Enter" button, the values should get populated in a row in excel, and repeat of the above activity next row... should be populated

upload_2015-6-4_16-50-50.png
 
corrected as per your suggestion and code is as below now

Private Sub Enter_Click()
row_number = 1
Do
DoEvents
row_number = row_number + 1
item_in_review = Sheets("Sheet1").Range("A2:M2" & 2)
If item_in_review = TextBox1.Text Then
TextBox1 = Sheets("Sheet1").Range("A2" & 2)
TextBox2 = Sheets("Sheet1").Range("B2" & 2)
TextBox3 = Sheets("Sheet1").Range("C2" & 2)
TextBox4 = Sheets("Sheet1").Range("D2" & 2)
TextBox5 = Sheets("Sheet1").Range("E2" & 2)
TextBox6 = Sheets("Sheet1").Range("F2" & 2)
TextBox7 = Sheets("Sheet1").Range("G2" & 2)
TextBox8 = Sheets("Sheet1").Range("H2" & 2)
TextBox9 = Sheets("Sheet1").Range("I2" & 2)
TextBox10 = Sheets("Sheet1").Range("J2" & 2)
TextBox11 = Sheets("Sheet1").Range("K2" & 2)
TextBox12 = Sheets("Sheet1").Range("L2" & 2)
TextBox13 = Sheets("Sheet1").Range("M2" & 2)
End If

Do
DoEvents

Loop Until item_in_review = Range("A2" & 10000)

End Sub
 
Can you please post the file ?

It makes it so much easier to solve your problems
Remember that we try to help lots of people not just you
If I have to remake that to test it that is time I might spend on someone else's problem?
 
Apologies; here it is

Private Sub ListBox1_Click()
the_slno = Sheet1.Range("a2:a10000")
the_phone_no = Sheet1.Range("b2:b10000")
the_name = Sheet1.Range("c2:c10000")
the_houseno_street = Sheet1.Range("d2:d10000")
the_locality = Sheet1.Range("e2:e10000")
the_pincode = Sheet1.Range("f2:f10000")
the_item = Sheet1.Range("g2:g10000")
the_qty = Sheet1.Range("h2:h10000")
the_rate = Sheet1.Range("i2:i10000")
the_total = Sheet1.Range("j2:j10000")
the_date_time = Sheet1.Range("k2:k10000")
the_cashier = Sheet1.Range("l2:l10000")

End Sub

UserForm1.TextBox1.Text = the_slno
UserForm1.TextBox2.Text = the_phone_no
UserForm1.TextBox3.Text = the_name
UserForm1.TextBox4.Text = the_houseno_street
UserFrom1.TextBox5.Text = the_locality
UserForm1.TextBox6.Text = the_pincode
UserForm1.TextBox7.Text = the_item
UserForm1.TextBox8.Text = the_qty
UserForm1.TextBox9.Text = the_rate
UserForm1.TextBox10.Text = the_total
UserForm1.TextBox11.Text = the_date_time
UserForm1.TextBox12.Text = the_cashier

UserForm1.Show


Private Sub Enter_Click()
row_number = 1
Do
DoEvents
row_number = row_number + 1
item_in_review = Sheets("Sheet1").Range("A2:M2" & row_number)
If item_in_review = TextBox1.Text Then
TextBox1 = Sheets("Sheet1").Range("A2" & row_number)
TextBox2 = Sheets("Sheet1").Range("B2" & row_number)
TextBox3 = Sheets("Sheet1").Range("C2" & row_number)
TextBox4 = Sheets("Sheet1").Range("D2" & row_number)
TextBox5 = Sheets("Sheet1").Range("E2" & row_number)
TextBox6 = Sheets("Sheet1").Range("F2" & row_number)
TextBox7 = Sheets("Sheet1").Range("G2" & row_number)
TextBox8 = Sheets("Sheet1").Range("H2" & row_number)
TextBox9 = Sheets("Sheet1").Range("I2" & row_number)
TextBox10 = Sheets("Sheet1").Range("J2" & row_number)
TextBox11 = Sheets("Sheet1").Range("K2" & row_number)
TextBox12 = Sheets("Sheet1").Range("L2" & row_number)
TextBox13 = Sheets("Sheet1").Range("M2" & row_number)
End If

Loop Until item_in_review = Range("")

End Sub



Private Sub UserForm_Click()

End Sub
 
Not the marco

The entire Excel file, not the code
 
Last edited:
Without seeing your file I think you need the following in

Code:
Private Sub Enter_Click()
Dim lr As Integer
lr = Range("A" & Rows.Count).End(xlUp).Row + 1

Sheets("Sheet1").Cells(lr, 1) = UserForm1.TextBox1.Text
Sheets("Sheet1").Cells(lr, 2) = UserForm1.TextBox2.Text
Sheets("Sheet1").Cells(lr, 3) = UserForm1.TextBox3.Text
Sheets("Sheet1").Cells(lr, 4) = UserForm1.TextBox4.Text
Sheets("Sheet1").Cells(lr, 5) = UserForm1.TextBox5.Text
Sheets("Sheet1").Cells(lr, 6) = UserForm1.TextBox6.Text
Sheets("Sheet1").Cells(lr, 7) = UserForm1.TextBox7.Text
Sheets("Sheet1").Cells(lr, 8) = UserForm1.TextBox8.Text
Sheets("Sheet1").Cells(lr, 9) = UserForm1.TextBox9.Text
Sheets("Sheet1").Cells(lr, 10) = UserForm1.TextBox10.Text
Sheets("Sheet1").Cells(lr, 11) = UserForm1.TextBox11.Text
Sheets("Sheet1").Cells(lr, 12) = UserForm1.TextBox12.Text
sheets("Sheet1").Cells(lr, 13) = UserForm1.TextBox13.Text

End Sub
 
Please see attached file:
 

Attachments

  • Vinoth_Customer data entry _billing.xlsm
    21.4 KB · Views: 0
Alt+F11
Double click on the Userform1 under Forms
Double click on the Userform
upload_2015-6-5_16-9-27.png
It isn't protected !
 
Back
Top