Run time error 1004

lac

New Member
Joined
Jun 28, 2011
Messages
5
my macro is showing "run time error 1004", how do I fix it? my code is below. I highlighted the error in red.

If Range("V1") = "3" Then
Columns("a:r").Select
Selection.EntireColumn.Hidden = False
Columns("e:h").Select
Selection.EntireColumn.Hidden = True
Columns("n:q").Select
Selection.EntireColumn.Hidden = True
Range("A1").Select
ElseIf Range("V1") = "4" Then
Columns("a:r").Select
Selection.EntireColumn.Hidden = False
Columns("f:h").Select
Selection.EntireColumn.Hidden = True
Columns("o:q").Select
Selection.EntireColumn.Hidden = True
Range("A1").Select
ElseIf Range("V1") = "5" Then
Columns("a:r").Select
Selection.EntireColumn.Hidden = False
Columns("g:h").Select
Selection.EntireColumn.Hidden = True
Columns("p:q").Select
Selection.EntireColumn.Hidden = True
Range("A1").Select
ElseIf Range("V1") = "6" Then
Columns("a:r").Select
Selection.EntireColumn.Hidden = False
Columns("H").Select
Selection.EntireColumn.Hidden = True
Columns("Q").Select
Selection.EntireColumn.Hidden = True
Range("A1").Select
ElseIf Range("V1") = "7" Then
Columns("a:r").Select
Selection.EntireColumn.Hidden = False
Range("A1").Select
Else
End If
End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hi Iac,

Can find nothing wrong with your code.

As you have had no reply, all though this may seem silly, sometimes just deleting the offending code line and retyping it fixes the problem.

If that does not work try this modified sub that doesn't select anything.

Code:
Sub ColControl()
If Range("V1") = "3" Then
    Columns("a:r").EntireColumn.Hidden = False
    Columns("e:h").EntireColumn.Hidden = True
    Columns("n:q").EntireColumn.Hidden = True
ElseIf Range("V1") = "4" Then
    Columns("a:r").EntireColumn.Hidden = False
    Columns("f:h").EntireColumn.Hidden = True
    Columns("o:q").EntireColumn.Hidden = True
ElseIf Range("V1") = "5" Then
    Columns("a:r").EntireColumn.Hidden = False
    Columns("g:h").EntireColumn.Hidden = True
    Columns("p:q").EntireColumn.Hidden = True
ElseIf Range("V1") = "6" Then
    Columns("a:r").EntireColumn.Hidden = False
    Columns("H").EntireColumn.Hidden = True
    Columns("Q").EntireColumn.Hidden = True
ElseIf Range("V1") = "7" Then
    Columns("a:r").EntireColumn.Hidden = False
End If
Range("A1").Activate
End Sub

Hope this is of some help
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,875
Members
452,949
Latest member
Dupuhini

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