Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 265
Default Help deffining public variables in userform1

Hi, I have a problem deffining my public variables in my userform, I have
with this problem 3 days and I can't solve it, could you helpme??? I attached
all my coding, the userform1 has 10 textboxes, one button to ADD a
registration (commandbutton1) and other to close the userform when user has
finished to use it (commandbutton2)

In my userform sheet:
Public maestro As String
Public clase1 As String
Public clase2 As String
Public clase3 As String
Public sueldo1 As Integer
Public horas1 As Integer
Public sueldo2 As Integer
Public horas2 As Integer
Public sueldo3 As Integer
Public horas3 As Integer
__________________________________________________ __________________
Private Sub CommandButton1_Click()
Dim b As Integer
maestro = TextBox1
clase1 = TextBox2
clase2 = TextBox3
clase3 = TextBox4
sueldo1 = TextBox5
horas2 = TextBox6
sueldo2 = TextBox7
horas3 = TextBox8
sueldo3 = TextBox9
horas3 = TextBox10

If maestro < "" Or clase1 < "" Or clase2 < 0 Or clase3 < 0 Then
agregarmaestro
Else
b = MsgBox("Debe de haber por lo menos los datos de un solo maestro, por
favor proporcionalos", vbOKCancel, "Error, falta informaciĆ³n")
If b = 2 Then
End
End If
End If
End Sub
__________________________________________________ ________________
Private Sub CommandButton2_Click()
End
End Sub

In my Module1 sheet:


Sub agregarmaestro()
a = ActiveSheet.Range("A1", Range("A65535").End(xlUp)).Count
Rows(a + 2).Select
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Range(Cells(a + 3, 1), Cells(a + 5, 1)).Select
With Selection
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Range(Cells(a + 3, 5), Cells(a + 5, 5)).Select
With Selection
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
UserForm1.Show
Cells(a + 3, 1) = TextBox1
Cells(a + 3, 2) = TextBox2
Cells(a + 3, 3) = TextBox3
Cells(a + 3, 4) = TextBox4
Cells(a + 4, 2) = TextBox5
Cells(a + 4, 3) = TextBox6
Cells(a + 4, 4) = TextBox7
Cells(a + 5, 2) = TextBox8
Cells(a + 5, 3) = TextBox9
Cells(a + 5, 4) = TextBox10
Cells(a + 3, 5).Formula = "=" & Cells(a + 3, 3).Address & "*" & Cells(a + 3,
4).Address & "+" & Cells(a + 4, 3).Address & "*" & Cells(a + 4, 4).Address &
"+" & Cells(a + 3, 3).Address & "*" & Cells(a + 3, 4).Address & "+" & Cells(a
+ 5, 3).Address & "*" & Cells(a + 5, 4).Address

End Sub

Why I cant use my variables in agregarmaestro macro
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Help deffining public variables in userform1

See post below ("Public Variable not maintaining value")
Try moving your public variables to the top of Module1 in your Modules folder.

"filo666" wrote:

Hi, I have a problem deffining my public variables in my userform, I have
with this problem 3 days and I can't solve it, could you helpme??? I attached
all my coding, the userform1 has 10 textboxes, one button to ADD a
registration (commandbutton1) and other to close the userform when user has
finished to use it (commandbutton2)

In my userform sheet:
Public maestro As String
Public clase1 As String
Public clase2 As String
Public clase3 As String
Public sueldo1 As Integer
Public horas1 As Integer
Public sueldo2 As Integer
Public horas2 As Integer
Public sueldo3 As Integer
Public horas3 As Integer
__________________________________________________ __________________
Private Sub CommandButton1_Click()
Dim b As Integer
maestro = TextBox1
clase1 = TextBox2
clase2 = TextBox3
clase3 = TextBox4
sueldo1 = TextBox5
horas2 = TextBox6
sueldo2 = TextBox7
horas3 = TextBox8
sueldo3 = TextBox9
horas3 = TextBox10

If maestro < "" Or clase1 < "" Or clase2 < 0 Or clase3 < 0 Then
agregarmaestro
Else
b = MsgBox("Debe de haber por lo menos los datos de un solo maestro, por
favor proporcionalos", vbOKCancel, "Error, falta informaciĆ³n")
If b = 2 Then
End
End If
End If
End Sub
__________________________________________________ ________________
Private Sub CommandButton2_Click()
End
End Sub

In my Module1 sheet:


Sub agregarmaestro()
a = ActiveSheet.Range("A1", Range("A65535").End(xlUp)).Count
Rows(a + 2).Select
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Range(Cells(a + 3, 1), Cells(a + 5, 1)).Select
With Selection
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Range(Cells(a + 3, 5), Cells(a + 5, 5)).Select
With Selection
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
UserForm1.Show
Cells(a + 3, 1) = TextBox1
Cells(a + 3, 2) = TextBox2
Cells(a + 3, 3) = TextBox3
Cells(a + 3, 4) = TextBox4
Cells(a + 4, 2) = TextBox5
Cells(a + 4, 3) = TextBox6
Cells(a + 4, 4) = TextBox7
Cells(a + 5, 2) = TextBox8
Cells(a + 5, 3) = TextBox9
Cells(a + 5, 4) = TextBox10
Cells(a + 3, 5).Formula = "=" & Cells(a + 3, 3).Address & "*" & Cells(a + 3,
4).Address & "+" & Cells(a + 4, 3).Address & "*" & Cells(a + 4, 4).Address &
"+" & Cells(a + 3, 3).Address & "*" & Cells(a + 3, 4).Address & "+" & Cells(a
+ 5, 3).Address & "*" & Cells(a + 5, 4).Address

End Sub

Why I cant use my variables in agregarmaestro macro

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
public variables johnny Excel Discussion (Misc queries) 7 February 27th 08 03:44 PM
Public variables johnny Excel Discussion (Misc queries) 2 February 24th 08 05:05 AM
Public Variables Jerry McNabb Excel Discussion (Misc queries) 0 February 24th 08 01:26 AM
Public Variables [email protected] Excel Programming 1 September 1st 05 04:14 PM
Public Variables ExcelMonkey[_190_] Excel Programming 5 February 21st 05 10:12 AM


All times are GMT +1. The time now is 12:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"