Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88066

VB application which creates entries in Excel

$
0
0

I have created Macros form with user input which adds value in Excel. I have 7 boxes and every entry is placed in dedicated column but now I would like to convert to .exe . I need to re-write my code in VB but I don't have any knowledge in this.

Can someone demonstrate how for example my first text box code should look like, if I need to make entry in Excel with VB app? I'm willing to learn and do this by myself but I would appreciate if someone could demonstrate first line.

Capture of my userform

Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
        Cells(Cells(Rows.Count, 1).End(xlUp).Row + 1, 1).Value = Name.Value
    End Sub
    Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
        Cells(Cells(Rows.Count, 2).End(xlUp).Row + 1, 2).Value = Surname.Value
    End Sub
    Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged
        Cells(Cells(Rows.Count, 3).End(xlUp).Row + 1, 3).Value = Address.Value
    End Sub
    Private Sub TextBox4_TextChanged(sender As Object, e As EventArgs) Handles TextBox4.TextChanged
        Cells(Cells(Rows.Count, 4).End(xlUp).Row + 1, 4).Value = City.Value
    End Sub
    Private Sub TextBox5_TextChanged(sender As Object, e As EventArgs) Handles TextBox5.TextChanged
        Cells(Cells(Rows.Count, 5).End(xlUp).Row + 1, 5).Value = Phone.Value
    End Sub
    Private Sub TextBox6_TextChanged(sender As Object, e As EventArgs) Handles TextBox6.TextChanged
        Cells(Cells(Rows.Count, 6).End(xlUp).Row + 1, 6).Value = Status.Value
    End Sub
    Private Sub TextBox7_TextChanged(sender As Object, e As EventArgs) Handles TextBox7.TextChanged
        Cells(Cells(Rows.Count, 7).End(xlUp).Row + 1, 7).Value = Occupation.Value
    End Sub

   Name.Value = ""
   Surname.Value = ""
   Address.Value = ""
   City.Value = ""
   Phone.Value = ""
   Status.Value = ""
   Occupation.Value = ""

   End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        UserForm1.Hide
    End Sub

End Class

Viewing all articles
Browse latest Browse all 88066

Trending Articles