Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8804477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:36:56+00:00 2026-06-14T01:36:56+00:00

I think this is a simple question but as I haven’t used excel in

  • 0

I think this is a simple question but as I haven’t used excel in this way before I am struggling. I am trying to create a program based in Excel VBA. I work in a call center. We have numerous excel sheets to log calls for different schemes. I have a project to streamline this process. So far I have created a workbook that has separate sheets named to represent each scheme. I have created a userform to gather information. One of the combo boxes indicates which scheme the call is in regards to. The input from the userform needs to be logged on to a sheet in the work book that corresponds to the name of the scheme selected in the combo box. I cant seem to get this close to working. Any suggestions or advice would be greatly appreciated!

The code I have is:

Private Sub cmdClear_Click()
Call UserForm_Initialize
End Sub


Private Sub cmdClose_Click()
Unload Me
End Sub


Private Sub ComboBox1_Change()
Dim ShtName As String
ShtName = ComboBox1.List(ComboBox1.ListIndex)
End Sub

Private Sub CommandButton1_Click()
Call Add_Data
End Sub

Private Sub Add_Data()
Dim Worksheets As Range
Dim ws As Worksheet
Dim UserForm As Object
Dim iRow As Long


    With Application
        .EnableEvents = False
        .ScreenUpdating = False
    End With

Set ws = this.ComboBox1.GetItemText(this.ComboBox1.SelectedItem)


'find first empty row in database
iRow = ShtName.Cells(Rows.Count, 1).End(x1up).Offset(1, 0).Row

'copy the data to the database
ws.Cells(iRow, 1) = Date
ws.Cells(iRow, 2) = Me.txtName.Value
ws.Cells(iRow, 3) = Me.txtNumber.Value
ws.Cells(iRow, 4) = ComboBox2.Value
ws.Cells(iRow, 5).Value = Me.txtQuery.Value

If optYes = True Then
        msgstr = "Yes"
    ElseIf optNo = True Then
        msgstr = "No"

End If

ws.Cells(iRow, 6).Value = msgstr



If chkMain = True Then
        msgstri = "Main"
    ElseIf chkExec = True Then
        msgstr = "Exec"
     Else
        msgstri = ""

End If

ws.Cells(iRow, 7).Value = msgstri
ws.Cells(iRow, 8).Value = Me.txtTime.Value




End Sub

Private Sub UserForm_Initialize()

ComboBox1.Clear
ComboBox1.AddItem ("Sheet2")
ComboBox1.AddItem ("Sheet3")
ComboBox1.AddItem ("Sheet4")
ComboBox1.AddItem ("Sheet5")
ComboBox1.AddItem ("Sheet6")
ComboBox1.AddItem ("Sheet7")
ComboBox1.AddItem ("Sheet8")
ComboBox1.AddItem ("Sheet9")
ComboBox1.AddItem ("Sheet10")
ComboBox1.AddItem ("Sheet11")
ComboBox1.AddItem ("Sheet12")

ComboBox2.Clear
ComboBox2.AddItem ("agent1")
ComboBox2.AddItem ("agent2")
ComboBox2.AddItem ("agent3")
ComboBox2.AddItem ("agent4")
ComboBox2.AddItem ("agent5")
ComboBox2.AddItem ("agent6")
ComboBox2.AddItem ("agent7")
ComboBox2.AddItem ("agent8")
ComboBox2.AddItem ("agent9")
ComboBox2.AddItem ("agent10")

txtNumber.Value = ""
txtName.Value = ""
txtQuery.Value = ""
txtTime.Value = ""

optYes = False
optNo = False
chkMain = False
chkExec = False

ComboBox1.SetFocus

End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T01:36:57+00:00Added an answer on June 14, 2026 at 1:36 am

    You should be getting an error at

     Set ws = this.ComboBox1.GetItemText(this.ComboBox1.SelectedItem)
    

    You are trying to set an object to a string. Try using

     Set ws = Sheets(this.ComboBox1.GetItemText(this.ComboBox1.SelectedItem))
    

    This will actually give you the ws object in that variable. Sheets is the collection of worksheets in the workbook. You can select by index number or by the name of the sheet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think this might be a pretty simple question, but I haven't been able
i think this is a simple question but I've searched around and can't seem
I think this is a simple question, but I can not find the answer
This is a simple question I think. I am trying to search for the
I think this question is probably fairly simple, but I've been searching around and
I think this may be a very simple question, but I am only just
I think this is a very simple question. but unfortunately I cannot find a
Simple question, I don't think it's possible but have been surprised before. I have
Sorry for the simple question but I can't think of a good way to
I think this has to be a very simple question but I am not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.