Thread: userform
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Antonov Antonov is offline
external usenet poster
 
Posts: 44
Default userform

Hello Rick, sorry to bother you again but here you see what the
CommandButton has to do already. I've tried to squeeze your formula in this
but it didn't work.
You are right when you say that I need the Userform to input the data. The
sheet which should give me the answer to put in the TextBox4 is LOADSHEET
and the cell is I53. I understood the formula you wrote but I don't know
where to fit it in the formula's below.


Private Sub CommandButton1_Click()
[a1].Activate
findvalue = UCase(ComboBox4.Value)
If Not ActiveSheet.UsedRange.Find(findvalue, lookat:=xlWhole,
matchcase:=True) Is Nothing Then
ActiveSheet.UsedRange.Find(findvalue, lookat:=xlWhole,
matchcase:=True).Activate
Else
MsgBox "The Position could not be found"
Exit Sub
End If
With ActiveCell
If Right(findvalue, 1) = "L" Then
If .Offset(-1, 0).Value = "" Then
If ActiveSheet.UsedRange.Find(ComboBox2.Value, lookat:=xlWhole)
Is Nothing Then
.Offset(-2, 0) = ComboBox2.Value
Else
MsgBox "Pallet already in use"
Exit Sub
End If
.Offset(-4, 0) = ComboBox1.Value
.Offset(-3, 0) = TextBox1.Value
.Offset(-1, 0) = TextBox2.Value
Else
MsgBox "Position is already taken"
Exit Sub
End If
Else
If .Offset(1, 0).Value = "" Then
If ActiveSheet.UsedRange.Find(ComboBox2.Value, lookat:=xlWhole)
Is Nothing Then
.Offset(3, 0) = ComboBox2.Value
Else
MsgBox "Pallet already in use"
Exit Sub
End If
.Offset(1, 0) = ComboBox1.Value
.Offset(2, 0) = TextBox1.Value
.Offset(3, 0) = ComboBox2.Value
.Offset(4, 0) = TextBox2.Value
Else
MsgBox "Position is already taken"
Exit Sub
End If
End If
End With
TextBox1.Value = ""
ComboBox1.Value = ""
TextBox2.Value = ""
ComboBox2.Value = ""
ComboBox3.Value = ""
ComboBox4.Value = ""
End Sub
"Rick" wrote in message
...
Antonov,

I think the reason it doesn't work, is because you want to
do something different. Now, I assume you want to use the
user form as a tool to help you with the data entry
(rather than just reading what the values are in a cell).
In that case, you switch around the one line of code
around. Maybe this will do what you want:

Private Sub cmdOK_Click()
Dim S2 As Worksheet
Set S2 = Sheets(2)
S2.Cells(10, 5).Value = Me.txtNo1.Value
End Sub

The way I have written it, the cmdOK button is the "enter"
button (the name is cmdOK, but the caption is "Enter").
The one text box is named "txtNo1".

After you understand what is written above, then you can
expand your userform into something more useful, like:

Private Sub cmdOK_Click()
Dim S2 As Worksheet
Set S2 = Sheets(2)
S2.Cells(10, 5).Value = Me.txtNo1.Value
S2.Cells(11, 5).Value = Me.txtNo2.Value
S2.Cells(12, 5).Value = Me.txtNo3.Value
End Sub

With three text boxes you can make three entries all at
the same time into three different cells, right below each
other. I hope that helps.

I'm using the Cells Method. Other programmers might give
you some different way of writing this with ranges. But
the Cells Method is an easy way for someone to understand,
when they are first starting out. I like looping through
the cells too...and that is my preferred method...but
everyone has their own favorite way. :)

-----Original Message-----
Hello Rick.
thanks for your reply. This is what I am trying to do:
when I am in a sheet I open a userform which I use to

input data. Everytime
I press an "Enter" button in the userform the data

influences a result in
sheet 2 (which has a different name, but for the

ease....).
I've tried what you sent but with no result.


"Rick" wrote in message
...
Hi,

Yes it's possible.

Sub ShowTheForm()
frmViewCells.Show vbModeless
End Sub

Private Sub cmdOK_Click()
Dim S2 As Worksheet
Set S2 = Sheets(2)
Me.txtNo1.Value = S2.Cells(10, 5).Value 'Col E, Row

10
End Sub

You could be on Sheet1 looking at a user form and

viewing
different cells on Sheet2 as I have shown. This just
shows a simple example. Is that what you were trying to
do?

-----Original Message-----
hello everybody. I have a question: I need a userform

to
have a cell or a
text box or whatever in which I can see the content of

a
cell in a workbook
(i.e. =sheet!2 e10). is it possible?


.



.