PDA

View Full Version : CODE CANT BE WORK



KK1966
06-24-2008, 01:55 AM
Dear Experts

This is my 1st time to learn aboutb the USERFORM AND HAVE CREAT ONE BUT HAVE NOT WORK !!:( CODE AS BELOW,

KINDLY PLEASE HELP TO SEE AND LEARN ME ABOUT WHAT'S WAS I MADE A WRONG ,,,THXX

WHAT'S THE USERFORM TO DO;

TEXTBOX 1 = WS SHEET1 COL: A COUNT THE BLANK ROWS.
TEXTBOX 2 = WS SHEET1 COL: B COUNT THE BLANK ROWS.
TEXTBOX 3 = WS SHEET1 COL: C COUNT THE BLANK ROWS.
TEXTBOX 4 = WS SHEET1 COL: D COUNT THE BLANK ROWS.

CODE:


Private Sub CommandButton1_Click()
Unload UserForm3
End Sub
Private Sub OKButton1_Click()
With Sheets("Sheet1")
Dim r As Long: r = Range("A" & Rows.Count).End(xlUp).Row + 1
Dim r As Long: r = Range("B" & Rows.Count).End(xlUp).Row + 1
Dim r As Long: r = Range("C" & Rows.Count).End(xlUp).Row + 1
Dim r As Long: r = Range("d" & Rows.Count).End(xlUp).Row + 1
TextBox1 = Range("A" & r).Value = Value
TextBox2 = Range("B" & r).Value = Value
TextBox3 = Range("C" & r).Value = Value
TextBox4 = Range("D" & r).Value = Value

End Sub

Private Sub TextBox1_Change()
Dim r As Long: r = Range("A" & Rows.Count).End(xlUp).Row + 1
Range("A" & r).Value = Value
End Sub

Private Sub TextBox2_Change()
Dim r As Long: r = Range("B" & Rows.Count).End(xlUp).Row + 1
Range("B" & r).Value = Value
End Sub

Private Sub TextBox3_Change()
Dim r As Long: r = Range("C" & Rows.Count).End(xlUp).Row + 1
Range("C" & r).Value = Value
End Sub

Private Sub TextBox4_Change()
Dim r As Long: r = Range("d" & Rows.Count).End(xlUp).Row + 1
Range("D" & r).Value = Value
End Sub
Private Sub UserForm_Click()
End Sub

Bob Phillips
06-24-2008, 02:04 AM
So it doesn't work. In what way? What does it do it shouldn't, or doesn't do that it should.

KK1966
06-24-2008, 02:14 AM
Dear XLD

Thanks your help & replying
When I put the values in the four TextBox, then OK, but the object WS has not showing the value I think the code has marking wrong and hope here someone help too,

I wan t to the userform to do is when I put a value in the textbox that?s should paste in object WS counts col A and rows blank to pasts.

Bob Phillips
06-24-2008, 02:42 AM
Surely; all you need is



Private Sub CommandButton1_Click()
Unload Me
End Sub


Private Sub OKButton1_Click()
Dim r As Long

With Sheets("Sheet1")
.Range("A" & .Range("A" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox1.Text
.Range("B" & .Range("B" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox2.Text
.Range("C" & .Range("C" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox3.Text
.Range("D" & .Range("d" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox4.Text
End With
End Sub

KK1966
06-24-2008, 03:08 AM
Thanks the help,
I still testing it what I is previously marking wrong before,
Although changed your code that?s the text can?t fall in to object WS?

Bob Phillips
06-24-2008, 04:06 AM
You will have to explain better and more comprehensively. Either I don't know what you are trying to do, or I don't understand what is wrong, or both.

KK1966
06-24-2008, 04:38 AM
Dear XLD

Thanks your help

I trying to describe what?s I want to do,

TextBox value = aim to Worksheet sheet1 form col A to down, count blank cells that?s faill in what was I type in the userform textbox,

Your code seem before work base the criteria, but I don?t know the background which is duplicated or wrong as I still in testing
Posted as here?s

Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub OKButton1_Click()
Dim r As Long

With Sheets("TEL_LIST")
.Range("A" & .Range("A" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox1.Text
.Range("B" & .Range("B" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox2.Text
.Range("C" & .Range("C" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox3.Text
.Range("D" & .Range("d" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox4.Text
End With
End Sub

Private Sub TextBox1_Afterupdate()
Dim r As Long: r = Range("A" & Rows.Count).End(xlUp).Row + 1

Range("A" & r).Value = Value
End Sub

Private Sub TextBox2_Afterupdate()
Dim r As Long: r = Range("B" & Rows.Count).End(xlUp).Row + 1

Range("B" & r).Value = Value
End Sub

Private Sub TextBox3_afterupdate()
Dim r As Long: r = Range("C" & Rows.Count).End(xlUp).Row + 1

Range("C" & r).Value = Value
End Sub

Private Sub TextBox4_afterupdate()
Dim r As Long: r = Range("d" & Rows.Count).End(xlUp).Row + 1

Range("D" & r).Value = Value
End Sub

Private Sub UserForm_Click()

End Sub

KK1966
06-24-2008, 04:38 AM
Dear XLD

Thanks your help

I trying to describe what?s I want to do,

TextBox value = aim to Worksheet sheet1 form col A to down, count blank cells that?s faill in what was I type in the userform textbox,

Your code seem before work base the criteria, but I don?t know the background which is duplicated or wrong as I still in testing
Posted as here?s

Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub OKButton1_Click()
Dim r As Long

With Sheets("TEL_LIST")
.Range("A" & .Range("A" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox1.Text
.Range("B" & .Range("B" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox2.Text
.Range("C" & .Range("C" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox3.Text
.Range("D" & .Range("d" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox4.Text
End With
End Sub

Private Sub TextBox1_Afterupdate()
Dim r As Long: r = Range("A" & Rows.Count).End(xlUp).Row + 1

Range("A" & r).Value = Value
End Sub

Private Sub TextBox2_Afterupdate()
Dim r As Long: r = Range("B" & Rows.Count).End(xlUp).Row + 1

Range("B" & r).Value = Value
End Sub

Private Sub TextBox3_afterupdate()
Dim r As Long: r = Range("C" & Rows.Count).End(xlUp).Row + 1

Range("C" & r).Value = Value
End Sub

Private Sub TextBox4_afterupdate()
Dim r As Long: r = Range("d" & Rows.Count).End(xlUp).Row + 1

Range("D" & r).Value = Value
End Sub

Private Sub UserForm_Click()

End Sub

Bob Phillips
06-24-2008, 04:59 AM
Sorry mate, I can't help, I just don't understand.

KK1966
06-24-2008, 05:09 AM
That's it ...but anyway ,thanks too much