runtime error applicationdefine

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Runtime error '1004' application-defined or object-defined error

Runtime error '1004' application-defined or object-defined error

resolvedResolved · Low Priority · Version 2007

Emma has attended:
Access Introduction course

Runtime error '1004' application-defined or object-defined error

Hi there,

I have written a macro to hide specified columns according to a dropdown box selection. The code itself is doing what I want it to do but when it reaches the end of the code the above error comes up and highlights a line of code. I have put my code below and have commented on the line where the error is. Has anybody got any idea how to sort it out?

Sub Hide_Columns()
Dim rowNum As Variant
Dim ColNum As Variant
Dim currcell As Range

rowNum = ActiveCell.Row
ColNum = ActiveCell.Column

Set currcell = ActiveSheet.Cells(rowNum, ColNum)
Do Until currcell.Value = " "
If currcell = Range("a4") Then
currcell.Select
Selection.EntireColumn.Hidden = True
End If
ColNum = ColNum + 1
' Line below has the error
Set currcell = ActiveSheet.Cells(rowNum, ColNum)
' Line above has the error
Loop

End Sub


This my first attempt at VBA so please bear in mind when responding.

Thank you!

RE: runtime error '1004' application-defined or object-defined e

Hi There,

I have sorted this now - I had put to stop when find a cell with a space in when i meant to stop at a blank cell.

Thanks

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Adjusting the Elevation and Rotation in a 3-D Chart

For any 3-D chart you create, you can adjust the chart

View all Excel hints and tips


Server loaded in 0.08 secs.