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!