+ Reply to Thread
Results 1 to 2 of 2

Help deffining public variables in userform1

Hybrid View

  1. #1
    filo666
    Guest

    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. #2
    Charlie
    Guest

    RE: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1