VBA can write into but not read from hidden columns?

EdNerd

Active Member
Joined
May 19, 2011
Messages
456
Using VBA, I set a MATCH formula down a range of cells in Col B. (Thank you, Stephan!) On this sheet, Cols A and B are normally hidden. The formula writes in fine, whether the columns are hidden or not. Then I want to run down the same range and check for errors returned by the formula. I use the following code:
VBA Code:
'Check for errors and advise
Set rng = wks.Range("B6:B" & rw)
strE = ""

For Each cll In rng.Cells
  If cll.Row > rw Then
    Exit For
  Else
    var = cll.Text
    Debug.Print cll.Address & ": " & var
    Debug.Print Len(cll.Text)
    Debug.Print Len(var)
    If IsNumeric(var) = False Then
      ''Debug.Print "Error!!"
      strE = strE & "TIR No. " & cll.Offset(0, 1).Text & _
                    " not found in this tracker on TIR sheet " & _
                    cll.Offset(0, -1).Text & "." & vbCrLf
    End If
  End If
Next cll

If the columns are visible, this works fine and only returns errors where I have deliberately changed values to induce an error to test my code. But if the columns are hidden, cll.Text (and so var) and cll.Offset(0, 1).Text are blank.

Is this just a property of hidden columns / cells?? Or is there something else I need in my code?
(Yes, I can work around it by unhiding the columns to run the macro and then re-hiding at the end. But I'd rather know if my code is off first.)
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,215,036
Messages
6,122,794
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top