Run-time error '1004' - worked in Excel 2003

tralfas1

New Member
Joined
Mar 22, 2011
Messages
1
Ok I have to try and fix the run-time error '1004' The VB code worked fine in excel 2003. Now it no longer works in Excel 2007. I suspect the issue is using With ActiveSheet.

Here is a snippet of the code:
--------------------------- START of snippet -----------------------
Dim found_freq_type As Boolean
Static saved_freq_type As String

found_freq_type = False 'Used to clear out frequency table
With ActiveSheet
.Unprotect password:="TCMS"

If FreqType_SZ.value = "Domestic Non-splinter" Then
.Range("start_band_info:end_band_info").EntireRow.Hidden = True
.Range("FreqTypeSZ_num").value = 1
SZ_Freq_NoN_OBT
found_freq_type = True
--------------------------- END of snippet -----------------------

If I try and debug the error it ends up on the line:
.Range("start_band_info:end_band_info").EntireRow.Hidden = True

I know that if I use a debugger watch window and try and see the value of:
.Range("start_band_info") I do not find an object.
IF I use watch window of
Range("start_band_info") I can see the value.

But the .Range is used throughout the code, editing all of them would be a pain.
I suspect the reason I can not use .Range is there is no object (sheet or workbook) to attach the .Range to.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Welcome to the Board!

What if you change:

.Range("start_band_info:end_band_info").EntireRow.Hidden = True

to:

.Range("start_band_info","end_band_info").EntireRow.Hidden = True

Does that work? Also make sure in 2007 what the scope of your named ranges are, you may need to change them from worksheet to workbook or something like that.
 
Upvote 0

Forum statistics

Threads
1,224,505
Messages
6,179,151
Members
452,891
Latest member
JUSTOUTOFMYREACH

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