Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 23rd, 2004, 05:17 AM
Registered User
 
Join Date: Dec 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default text box value to excel spreadhseet

Good Morning,

What I would like to acheive is as follows, should the txt_month = "December", I would like the txt_revenue, txt_budger, txt_forecast to put the value in cells 4,4, 4,6, 4,7 etc etc. However when the txt_month = "january, I would like them to into 5,4, 5,6 etc etc

I hope someone out there can help me? I am confused with this

Kindest regards,

Alan

 
Old December 23rd, 2004, 06:11 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try something like this:

Dim iRow As Integer
Dim mnt As String

mnt = Application.Sheets("Sheet1").TextBox1.Text

Select Case mnt
    Case "december"
        iRow = 4
    Case "january"
        iRow = 5
End Select

Cells(iRow, 4).Value = Application.Sheets("Sheet1").TextBox2.Text
Cells(iRow, 5).Value = Application.Sheets("Sheet1").TextBox3.Text
Cells(iRow, 6).Value = Application.Sheets("Sheet1").TextBox4.Text
 
Old December 23rd, 2004, 06:19 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Substitute with this line:

mnt = LCase(Application.Sheets("Sheet1").TextBox1.Text)

Then you dont have to worry about the spelling in the textbox. Just remember to write the monthnames in the Case Select in lowercase.
 
Old December 23rd, 2004, 09:55 AM
Registered User
 
Join Date: Dec 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your help, its still not working, it says that it doesnt support object!
HELP!

 
Old December 25th, 2004, 12:31 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In the editor, check you have the necessary references set. I'm running on a new install of Office and haven't added any references myself. It works for me with these references set under Tools - References:

  Visual Basic for Applications
  Microsoft Excel xx.0 Object Library
  Ole Automation and
  Microsoft Office xx.0 Object Library

If this is not the cause to the error, try telling me on which line your code stops with an error. The codeline should be marked yellow.

You may also try to debug your code. Set a breakpoint (before) where you suspects the code to fail and when the execution stops, use F8 to take one step at a time.
You should then be able determine the line causing the error.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Grab Values From List Box into Text Box phungleon VB How-To 2 June 19th, 2008 10:33 PM
Count in combo box(display results in text box) mboyisis Access 4 April 4th, 2008 07:08 AM
Extract text from text file & put in dropdown box tsukey Beginning PHP 5 July 20th, 2004 09:49 PM
Rich Text Box vs Text Box snowy0 VB.NET 2002/2003 Basics 1 February 17th, 2004 02:11 PM
Search using drop down list box and a text box tcasp Classic ASP Basics 1 July 31st, 2003 02:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.