I'm very new at VBA and struggling. I have a spreadsheet that allows 26 accounts to be listed. Since the user will likely have less than 26 accounts, I want to hide the columns associated with unused account accounts. Each account is comprised of two columns, one has the account name and the second contains balance information. Currently I've entered IF formulas in each "name" cell looking for a "name" in the previous account field, if no "name" is present the IF displays an * in the next name field. My macro then hies all columns with an * in the appropriate row. The macro is also triggered by clicking a button. I'd prefer some sort of automatic triggering as soon as "anything" is entered in a "name" cell.

It seems there should be a more efficient way to simply have the macro look for any content in the name cells and hide/unhide accordingly. I want one blank account field to always display, so the user knows where to enter a new account, but not have 10, 15, 20 blank accounts listed all the time. Below is the code I have. Any suggestions for improvement?

Sub HideCols()

Sheets("Budgeted").Unprotect

Dim rng As Range
Set rng = Range("Budgeted!e7:co7")
For Each cell In rng
If InStr(cell, "*") Then
cell.EntireColumn.Hidden = True
Else
cell.EntireColumn.Hidden = False
End If
Next
Sheets("Budgeted").Protect
End Sub

Thanks in advance.