How to Fix Error - Defining a range of cells in a VBA hide/unhide column function?

Defining a range of cells in a VBA hide/unhide column function

I am a beginner with VBA, so if I am asking the obvious, I apologize.
This is a script I adapted and wrote.
It a value of "--" appears in a given cell of row 4, it will hide a column.
If something else is inputted (from a dropdown list) a column will appear dynamically and show the result of a calculation.
For example, in
column e, row 4, I have a value of 100$.
If the drop down list default is "--" in column f, column h will not appear.
However if I choose Mint from column f, it will do a calculation using a formula in column g and show the result in column H.
Column G always
remains hidden.
The code is
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Range("F4").Value = "--" Then
        Columns("H").EntireColumn.Hidden = True
            Columns("H").EntireColumn.Hidden = False
    End If
    If Range("i4").Value = "--" Then
        Columns("k").EntireColumn.Hidden = True
            Columns("k").EntireColumn.Hidden = False
    End If
    If Range("L4").Value = "--" Then
        Columns("N").EntireColumn.Hidden = True
            Columns("N").EntireColumn.Hidden = False
    End If
    If Range("O4").Value = "--" Then
        Columns("Q").EntireColumn.Hidden = True
            Columns("Q").EntireColumn.Hidden = False
    End If
    If Range("R4").Value = "--" Then
        Columns("T").EntireColumn.Hidden = True
            Columns("T").EntireColumn.Hidden = False
    End If
End Sub
What I am trying to do now is to make this function work on all cells in any given column.
It works now on Col E row 4, but not 5.
I know it is a range issue, but everything I have been trying results in an error.
Thanks for you patience.

Solutions to the Problem Defining a range of cells in a VBA hide/unhide column function

Download Error Fixer for Free Now

This include the previous suggestions:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
Set isect = Intersect(Target, Range("F4:F100,I4:I100,L4:L100,Q4:Q100,R4:R100"))
If Not isect Is Nothing Then
    If Target.Value = "--" Then
        Target.Offset(0, 2).EntireColumn.Hidden = True
        Target.Offset(0, 2).EntireColumn.Hidden = False
    End If
End If
End Sub
Regarding the formula, I would use something like:
=If(F4="",Estimated Price, Average formula)

Using Windows troubleshooter:

  • Click on Search on Charm bar and type Troubleshooting. Click on the very first option.
  • A new window will open. Click View all from the left pane.
  • Scroll down to the bottom and click on Windows update.
  • Troubleshooter window for Windows update will pop up. Click on NEXT. It may ask you for administrative permission.
  • The troubleshooter will automatically detect problems and fix it.
  • Now, close this window and try download/install the app which was previously showing error.

Another Safe way to Repair the Problem: Defining a range of cells in a VBA hide/unhide column function:

How to Fix Defining a range of cells in a VBA hide/unhide column function with SmartPCFixer?

1. Click the button to download SmartPCFixer . Install it on your computer.  Open it, and it will perform a scan for your computer. The junk files will be shown in the list.

2. After the scan is finished, you can see the errors and problems need to be fixed. Click Fix All.

3. The Fixing part is finished, the speed of your computer will be much higher than before and the errors have been removed.

Related: How to Update & Download NVidia GeForce 6100/nForce 420 WHQL Certified driver v.178.13,How to Update & Download NVidia GeForce 7600 GS Video Driver v.295.75 Certified,How Can I Update & Download NVidia GeForce 820M Driver v.344.48 WHQL,[Solved] Download NVidia GeForce GTX 560M VGA Driver v.296.17 Certified,Way to Update & Herunterladen NVidia GeForce GT 130M Video Treiber v.295.75 Certified,How to Update & Download SONY SVE14A1X1RH Realtek Ethernet Driver,Where to Download SONY SVS13A2W9ES Bluetooth Driver (Intel) v.2.6 -,Best Way to Update & Download SONY VGN-CR203E Conexant HDAUDIO SoftV92 Data Fax Modem with SmartCP Setup Program v. driver,Best Way to Download SONY VGN-FE790G/N Wireless LAN Driver v.,Method to Update & Download SONY VGN-NR31Z/S Firmware Extension Parser Device v.,How to Fix Error 0x0000c1f5 Solución?,Error 0x80071a91 Win7 Fix Patch,Error 0x800ccc60 Windows Live Mail [Solved],Error Message 0x800ccc79 Outlook 2000 Fix,What is Error 0xc1ab0001?,[Answered] x64 saplugin dll,How to Fix Problem - Kb943729 Download?,Troubleshooting: Bccode D1 Error,Java Runtime Tech Support,Troubleshooting: ERROR NO SUCH GROUP Error
Read More: How Can You Fix - Desktop gadget calendar?,desktop gadget calendar not showing date [Anwsered],Fast Solution to Problem: Defrag will not start due to Task Scheduler service not running.,Troubleshoot:DEFRAG on windows 7,DCOM Server Process Launcher quit unexpectedly [Solved]