runtime error applicationdefine
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

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

replyReply Thu 26 Feb 2009, 11:02Delegate Emma said...

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!

For upcoming training course dates see: Pricing & availability

replyReply Mon 2 Mar 2009, 12:17Delegate Emma said...

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

 

Please browse our web site to find out more about
excel-courses and other Microsoft training courses.

Excel tip:

Closing Multiple Workbooks quickly

When you have several workbooks open in Excel and want to just close them all at once:

1) Hold down the SHIFT key before selecting the File menu.

2) Once in File menu release SHIFT key and select Close All option.

3) All your files will close. If files require saving Excel will ask if you want to save the changes.

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard