rcarmichael
New Member
- Joined
- Aug 10, 2012
- Messages
- 29
- Office Version
- 2016
- Platform
- Windows
Good afternoon,
I have some VBA triggered by a button in a workbook that will automatically hide/show a series of columns (A:CC) if the corresponding cell in ROW(8) contains "NZ".
This code works well, but instead of searching for the text "NZ", I want to search for the special character/s "".
I have tried replacing "NZ" with "" by pasting in the special character/s but it results in "????".
I then tried replacing "NZ" with UNICHAR(127475) which results in a "Compile error: Sub or Function not defined" on the
I then tried replacing "NZ" with Chrw(127475) which results in a "Run-time error '5': Invalid procedure call or argument" on the
Any idea what I'm doing wrong, or if what I'm trying to do is even possible?
Sincere regards,
Ryan
I have some VBA triggered by a button in a workbook that will automatically hide/show a series of columns (A:CC) if the corresponding cell in ROW(8) contains "NZ".
VBA Code:
Private Sub NZToggle_Click()
Dim SrchRng As Range, cel As Range
If NZToggle.Caption = "Hide NZ" Then
'Hide "New Zealand"
Set SrchRng = Range("A8:CC8")
For Each cel In SrchRng
If InStr(1, cel.Value, "NZ") > 0 Then
cel.EntireColumn.Hidden = True
End If
Next cel
NZToggle.Caption = "Show NZ"
Else
'Show "New Zealand"
Set SrchRng = Range("A8:CC8")
For Each cel In SrchRng
If InStr(1, cel.Value, "NZ") > 0 Then
cel.EntireColumn.Hidden = False
End If
Next cel
NZToggle.Caption = "Hide NZ"
End If
End Sub
This code works well, but instead of searching for the text "NZ", I want to search for the special character/s "".
I have tried replacing "NZ" with "" by pasting in the special character/s but it results in "????".
I then tried replacing "NZ" with UNICHAR(127475) which results in a "Compile error: Sub or Function not defined" on the
Unichar
step.I then tried replacing "NZ" with Chrw(127475) which results in a "Run-time error '5': Invalid procedure call or argument" on the
If InStr(1, cel.Value, ChrW(127475)) > 0 Then
step.Any idea what I'm doing wrong, or if what I'm trying to do is even possible?
Sincere regards,
Ryan