Help please? Run-time error 1004: Activate method of Range class failed

raeannb

Board Regular
Joined
Jun 21, 2011
Messages
86
Hi! I'm sorry for any trouble, but I am getting a horrible runtime error that I can't figure out. The error is "Run-time error '1004': Activate method of Range class failed." I've pasted some of my code below. I have two workbooks open - one containing the macro code, and the other containing the data and both worksheets ("C21004," where the data comes from, and "Discrepancies," where I want it to go). The code works beautifully until I want to output it on another worksheet. I've been able to output the array to a MsgBox so I know it has the data stored successfully. I've checked my spelling, tried renaming the worksheet, tried using "Select" instead of "Activate," and tried first activating the workbook. Nothing helps! I've done very similar code before, so I don't understand what the problem is. Help would be AWESOME. Thank you!!


Sheets("C21004").Range("D3").Select
For i = 0 To x
If IsEmpty(ActiveCell) = False Then
' ...a lot of code which basically writes data from sheet "C21004" to a two-dimensional array...
Else: GoTo Display:
End If
Next i
'Here I'm trying to output the array into a table on a separate worksheet called "Discrepancies"
Display:
Sheets("Discrepancies").Range("A4").Activate 'This is where I get the error
ActiveCell.Value = a(0, 1)
ActiveCell.Offset(0, 1).Value = a(0, 2)
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Nevermind! So so sorry...all I needed was a quick little "Application.GoTo" action and it worked. Thanks anyway!
 
Upvote 0

Forum statistics

Threads
1,224,507
Messages
6,179,183
Members
452,893
Latest member
denay

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