Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
UserForm code help needed.
Thanks to all who helped me yesterday. You were so helpful I thought I'
throw my other VBA problem into the ring. What I've got is a Userform for users to input address details, whic then puts those details into an excel sheet when a button is clicked (The intention is eventually to mailmerge the details and print a shee of address labels) Unfortunately, it keeps putting the address details on the same line until you try and close the form, when it gets stuck in a loop. Hope someone can help. Here's the userform code Public Sub InputButton_Click() 'set up variables Dim Check Dim Activerow As Variant Dim StartCellRow As Integer Dim StartCellColumn As Integer Dim Printbutt As Integer Dim Title As String Dim FirstName As String Dim Surname As String Dim Address1 As String Dim Address2 As String Dim Address3 As String Dim Address4 As String Dim Postcode As String Dim Todaydate As String Dim ID As String Dim form As String 'fill variables with info from form Check = True Title = Titlebox FirstName = TxtFirstname Surname = TxtSurname Address1 = TxtAddress1 Address2 = TxtAddress2 Address3 = TxtAddress3 Address4 = TxtAddress4 Postcode = TxtPostcode Todaydate = TxtDate ID = TxtLoginID form = Formbox Today = Format(Date, "d/mm/yyyy") StartCellRow = "1" StartCellColumn = "1" Printbutt = "1" 'check this works Do ActiveCell(StartCellRow, StartCellColumn) = Title StartCellColumn = StartCellColumn + 1 ActiveCell(StartCellRow, StartCellColumn) = FirstName StartCellColumn = StartCellColumn + 1 ActiveCell(StartCellRow, StartCellColumn) = Surname StartCellColumn = StartCellColumn + 1 ActiveCell(StartCellRow, StartCellColumn) = Address1 StartCellColumn = StartCellColumn + 1 ActiveCell(StartCellRow, StartCellColumn) = Address2 StartCellColumn = StartCellColumn + 1 ActiveCell(StartCellRow, StartCellColumn) = Address3 StartCellColumn = StartCellColumn + 1 ActiveCell(StartCellRow, StartCellColumn) = Address4 StartCellColumn = StartCellColumn + 1 ActiveCell(StartCellRow, StartCellColumn) = Postcode StartCellColumn = StartCellColumn + 1 ActiveCell(StartCellRow, StartCellColumn) = Today StartCellColumn = StartCellColumn + 1 ActiveCell(StartCellRow, StartCellColumn) = ID StartCellColumn = StartCellColumn + 1 ActiveCell(StartCellRow, StartCellColumn) = form StartCellRow = StartCellRow + 1 StartCellColumn = "1" 'this bit is to try and clear the form ready for the next input Unload UserForm1 UserForm1.Show Loop Until Check = False End Sub 'when this button is clicked, check should equal false 'and the form should be closed Public Sub PrintButton_Click() Check = False End Su -- Message posted from http://www.ExcelForum.com |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
NEED A MACRO CODE TO USE IN A USERFORM | Excel Discussion (Misc queries) | |||
Amount of code in UserForm | Excel Programming | |||
Userform Formula Help Needed | Excel Programming | |||
VBA code for Userform | Excel Programming | |||
A pointer or two needed using userform | Excel Programming |