By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,191 Members | 1,067 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,191 IT Pros & Developers. It's quick & easy.

Reading data directly from a spreadsheet

P: 48
I am trying to read the data directly from an Excel file into a text box. i keep getting this error OBJECT REQUIRED
here is my code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub CboMS_AfterUpdate()
  2.  With worksheets = ("C:\todays\Small Pricing.xls")
  3.  
  4.     If Me.CboMS.ListIndex <> -1 Then
  5.  
  6.           'MsgBox ("[" & Me.CboMonth & "]")
  7.           MsgBox ("[" & .range("D16").Value & "]")
  8.             Select Case Me.CboMS.ListIndex
  9.                 Case 0
  10.                 Select Case Me.CboZS.ListIndex
  11.  
  12.                    Case 0
  13.                         Me.txt_6MS = .range("D15").Value
  14.                    Case 1
  15.                         Me.txt_6MS = .range("D16").Value
  16.                     Case 2
  17.                         Me.txt_6MS = .range("D17").Value
  18.                     Case 3
  19.                         Me.txt_6MS = .range("D18").Value
  20.                     Case 4
  21.                        Me.txt_6MS = .range("D19").Value
  22.                End Select
  23.                'i have some code in here different 
  24.             End Select
  25. End If
  26. End With
  27. End Sub
  28.  
the error is on line 6 but basically it's every line that has .range in it.
Dec 16 '11 #1
Share this Question
Share on Google+
3 Replies


NeoPa
Expert Mod 15k+
P: 31,494
You should never post a question with code without first considering the points in When Posting (VBA or SQL) Code.

Your first line is not proper code and wouldn't compile. Of course none of the rest of it will work. Please check the basics before posting more questions.
Dec 16 '11 #2

P: 48
Sorry about that. I have edited the post and the code is now complete
Dec 16 '11 #3

NeoPa
Expert Mod 15k+
P: 31,494
I don't know how to respond to that.

Line #2 is still nonsense and the code will clearly not compile due at least to this (if not other problems too). You need to follow the instructions in the linked article and compile the code first. It won't compile as line #2 isn't recognisable code. I can't think how I can make the point any clearer.
Dec 16 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.