LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
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
NEED A MACRO CODE TO USE IN A USERFORM Rachel Excel Discussion (Misc queries) 3 November 25th 08 10:08 AM
Amount of code in UserForm RB Smissaert Excel Programming 7 December 20th 03 07:16 PM
Userform Formula Help Needed timh2ofall Excel Programming 2 December 12th 03 10:55 PM
VBA code for Userform Martin Los Excel Programming 4 December 5th 03 03:04 PM
A pointer or two needed using userform Jim[_32_] Excel Programming 1 October 20th 03 06:04 PM


All times are GMT +1. The time now is 07:09 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"