Getting a 1004 error but I can't figure out why

skendzie

New Member
Joined
Oct 22, 2014
Messages
6
I have 3 spreadsheets. One form to enter the information, and two different spreadsheets that the information goes into (9月Spares, 9月Project). I have an activex button and two options and to be honest I'm kind of experimenting with them. The code executes if you click the "Enter" Button.

If it Spares is selected, the info should go into the Spares spreadsheet. But I keep getting a application/object defined error when I try select one of the sheet's range. I have no idea why!

Code:
Private Sub Input_Button_Click()
     
     Dim data As Range
     Dim spwksh As Worksheet
     Dim pjwksh As Worksheet
     
               
     Set data = Sheets("Plugin Form").Range("A32:GX32")
     Set spwksh = Sheets("9月Spares")
     Set pjwksh = Sheets("9月Project")
     
     Range("A32").Value = TextBox_Cusname
     Range("C32").Value = TextBox_InvoiceNum
     Range("D32").Value = TextBox_Sales
     Range("F32").Value = TextBox_Cost
     
    If Select_SpareParts.Value = True Then
       
        spwksh.Range("A5").Activate
   
        End If
    
    If Select_Projects.Value = True Then
        
        pjwksh.Range("A5").Activate
        
        End If
        
End Sub

Thanks so much in advance!
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
You can't activate a range on a sheet that's not the active sheet.
 
Upvote 0
Before you can activate a range on a sheet, the sheet must be selected.

Change this...
spwksh.Range("A5").Activate

To this...
spwksh.Select
Range("A5").Activate



Or use the Aplication.GoTo method
Application.GoTo spwksh.Range("A5")
 
Upvote 0
I still get the same error :(

Nevermind! The ApplicationGoto worked like a charm! I wonder why the first combination of spwksh.Activate Range("A5").Select doesn't work...
 
Upvote 0

Forum statistics

Threads
1,214,821
Messages
6,121,762
Members
449,048
Latest member
excelknuckles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top