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

runtime error applicationdefine

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

ResolvedVersion 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:

The Easiest Way to See a Sum or Average in Excel 2010

Did you know the quickest and most simple way of working out the average or sum of a set of numbers?

Highlight numbers in cells or type some numbers in cells and then look at the status bar at the bottom of the window. Here you will see a display of the average of the numbers, as well as a count of the cells and the sum of these cells.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.08 secs.