Question:

I am new to Visual Basic. Trying to put a userform together with combo boxes but data is duplicating?

by  |  earlier

0 LIKES UnLike

And when trying to put the data into a new spreadsheet it is not working?

Private Sub PhoneInternet_Enter()

InputForm.PhoneInternet.AddItem ("Internet")

InputForm.PhoneInternet.AddItem ("Phone")

InputForm.PhoneInternet = ""

InputForm.PhoneInternet.MatchRequired = True

End Sub

Private Sub SizeContract_Enter()

InputForm.SizeContract.AddItem ("1000")

End Sub

Private Sub UpdateButton_Click()

InputSheetName = "Writing"

StockCodeValue = InputForm.StockCode.Value

StrikePriceValue = InputForm.StrikePrice.Value

TransactionDateValue = InputForm.TransactionDate.Value

PremiumValue = InputForm.Premium.Value

OptionCodeValue = InputForm.OptionCode.Value

PhoneInternetValue = InputForm.PhoneInternet.Value

NoContracts = InputForm.NoContracts.Value

SizeContract = InputForm.SizeContract.Value

ExpiryDate = InputForm.ExpiryDate.Value

ActiveWorkbook.Worksheets(InputSheetNa...

Dim Home As Range

Set Home = Range("A1")

Home.Offset(3, 0).Select

Range(Selection, Selection.End(xlToRight)).Select

Dim NumColsUsed As Integer

NumColsUsed = Selection.Columns.Count

Home.Offset(0, NumColsUsed).Value = StockCodeValue

Home.Offset(6, NumColsUsed).Value = StrikePriceValue

Home.Offset(4, NumColsUsed).Value = TransactionDateValue

Home.Offset(9, NumColsUsed).Value = PremiumValue

Home.Offset(1, NumColsUsed).Value = OptionCodeValue

Home.Offset(3, NumColsUsed).Value = PhoneInternetValue

Home.Offset(7, NumColsUsed).Value = NoContractsValue

Home.Offset(8, NumColsUsed).Value = SizeContractValue

Home.Offset(5, NumColsUsed).Value = ExpiryDateValue

End Sub

 Tags:

   Report

3 ANSWERS


  1. you may find your answer here

    http://visualbasic.freetutes.com


  2. What have you got?

    Is it Visual Studio 2007?

  3. To answer the 1st part of your question:

    You are currently adding entries to your "PhoneInternet" field each time it is entered (i.e. someone clicks in it).

    You should enter the code to populate the combobox in the "Initialize" event of the form - you can double-click the form and then choose initialize from the top-right.

    To answer the 2nd part can you please post more detail about what you are trying to achieve.

Question Stats

Latest activity: earlier.
This question has 3 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.