Results 1 to 6 of 6

Compile Error: Object Required, while reading integer values from textbox on button click

Threaded View

  1. #1
    Registered User
    Join Date
    05-18-2016
    Location
    Jersey City
    MS-Off Ver
    MS2007
    Posts
    3

    Unhappy Compile Error: Object Required, while reading integer values from textbox on button click

    Please see my code below and advise. I am getting the error at the arrow marked steps.
    Getting 'Compile Error: Object Required' for the below. And when I remove the 'Set' in the below, I get 'Runtime error 424: Object Required'
    Sub Button1_Click()
    Dim wb1 As Workbook
    Dim wb2 As Workbook
    Dim Year As Integer
    Dim Month As Integer
    Set Month = Val(TextBox2.Text) <---
    Set Year = Val(TextBox1.Text) <---
    
    Set wb1 = Workbooks.Open("C:\Users\Sreek\Desktop\Others\Project Files\Macro_Experiment\TCOE Consumption " & Month & Year & ".xlsx")
    Set wb2 = Workbooks.Open("C:\Users\Sreek\Desktop\Others\Project Files\Macro_Experiment\TCOE Consumption Staging Sheet " & Month & Year & ".xlsx")
    
    wb1.Sheets("TCOE Cost model Information").Range("A2:E1000000").Copy
    wb2.Sheets("TCOE Cost model Information").Activate
    Range("A2").Select
    ActiveSheet.Paste
    
    Range("A1").Select
    
    wb2.Save
    
    wb1.Close SaveChanges:=True
    wb2.Close SaveChanges:=True
    
    MsgBox "TCOE Staging sheet is created"
    
    End Sub
    Last edited by Sreekanthev; 05-18-2016 at 03:40 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Compile Error - Object Required when opening Userform on another PC
    By Scoobymoo in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-13-2015, 05:48 AM
  2. [SOLVED] Compile Error: Method or data member not found when i click Save button...
    By aditbaco in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-15-2013, 07:11 AM
  3. [SOLVED] Object Required Error - Need to modify button
    By jeff_kaufman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2013, 12:19 PM
  4. Compile error: Object required
    By Hinnerk in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-23-2012, 04:38 PM
  5. Object required error on CommandButton Click
    By rkjudy in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-09-2011, 06:05 PM
  6. Compile error : object required in userform
    By asha3010 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-09-2010, 04:08 AM
  7. [SOLVED] VBA Help needed -- compile error: object required
    By alexandraVBAgirl in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-17-2006, 09:00 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1