Can VBA find a "?" in a row?

raeannb

Board Regular
Joined
Jun 21, 2011
Messages
86
I'm trying to find any cells in my table that have the entry "???" but sadly VBA is just reading the ?s as wildcards. Is there any way to make it specifically find the characters? Thank you!
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Have you tried changing the search to Char(63) instead of ?
 
Upvote 0
Ok so I tried "Char(63)" and got an error, but "Chr(63)" worked error-free. The down side: neither found my question mark line. Here's the code I'm using:

ElseIf WorksheetFunction.CountIf(Selection, Chr(63)) > 0 Then
ActiveCell.EntireRow.Interior.ColorIndex = 3

Thoughts? And thank you!!
 
Upvote 0
This has been tested and works

If InStr(1, Range("A1"), Chr(63)) > 0 Then ' found a ? in A1
MsgBox "Found you"
End If

and so does this

If WorksheetFunction.CountIf(Selection, Chr(63)) > 0 Then
ActiveCell.EntireRow.Interior.ColorIndex = 3
End If
 
Upvote 0
Oy...still doesn't work for me. I just copied in your code and nuthin'. I'll try to take a different approach...suggestions are welcome :)
 
Upvote 0
This code will find and select all the instances of ??? in the active worksheet.
It could be adapted to do whatever else you need to do to these cells

Code:
Sub findQmark()
    Dim fa As String, fr As Range, ft As Range
    Set fr = Cells.Find(what:="~???")
    If Not fr Is Nothing Then
        fa = fr.Address
        Set ft = fr
        Do
            Set ft = Union(ft, fr)
            Set fr = Cells.FindNext(fr)
        Loop Until fr.Address = fa
        ft.Select 'this is your range of 'hits'
    Else
        MsgBox "Nothing found"
    End If
End Sub
Note, it's the use of the tilde (~) character before the question mark that tells Excel you're not performing a wildcard search and to take the '?' literally.

HTH
 
Upvote 0
It worked!! Thank you all so much for your help. I am one happy camper. Also - if anyone has any thoughts on getting better at this VBA stuff, I'd love to get some pointers. I would say I'm on the beginner side of intermediate when it comes to writing macros, but my new job involves mucho macro-ing. I'm getting better just with practice and trial/error, but if anyone has suggestions regarding reference books or tutorials or whatnot, I'd love some tips. Thanks again!!
 
Upvote 0
A couple of free tips....
1. Keep hanging around here and asking questions
2. Keep up the trial and error

and finally, if you need books / reference, etc.
This posted by hiker95
Code:
Training / Books / Sites:

How to Learn to Write Macros 
http://articles.excelyogi.com/playin...ba/2008/10/27/

How to use the macro recorder 
http://articles.excelyogi.com/

Click here and scroll down to Getting Started with VBA. 
http://www.datapigtechnologies.com/ExcelMain.htm

If you are serious about learning VBA try 
http://www.add-ins.com/vbhelp.htm

Excel Tutorials and Tips - VBA - macros - training 
http://www.mrexcel.com/articles.shtml

See David McRitchie's site if you just started with VBA
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Debra Dalgleish has some notes how to implement macros here:
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

Creating custom functions
http://office.microsoft.com/en-us/ex...117011033.aspx

Writing Your First VBA Function in Excel
http://www.exceltip.com/st/Writing_Y...Excel/631.html

http://www.excel-vba.com/
http://www.mvps.org/dmcritchie/excel/getstarted.htm
http://www.exceltip.com/excel_links.html

(livelessons video)
Excel VBA and Macros with MrExcel
ISBN: 0-7897-3938-0
http://www.amazon.com/Excel-Macros-M...7936479&sr=1-1

http://www.xl-central.com/index.html

http://www.datapigtechnologies.com/ExcelMain.htm

Dependent validation lists. Debra has a neat little tutorial here.
http://www.contextures.com/xlDataVal02.html 

Cascading queries
http://www.tushar-mehta.com/excel/ne...ing_dropdowns/

http://www.contextures.com/xlDataVal05.html 


Excel Data Validation - Add New Items
http://www.contextures.com/excel-dat...ation-add.html

Programming The VBA Editor - Created by Chip Pearson at Pearson Software Consulting LLC
This page describes how to write code that modifies or reads other VBA code.
http://www.cpearson.com/Excel/vbe.aspx

Locating files containing VBA
Searching Files in Subfolders for VBA code string:
http://www.dailydoseofexcel.com/arch...a-code-string/

http://www.pcreview.co.uk/forums/thread-978054.php

Excel 2003 Power Programming with VBA, by John Walkenbach

VBA and Macros for Microsoft Excel, by Bill Jelen "Mr.Excel" and Tracy Syrstad

Excel Hacks 100 Industrial-Strength Tips & Tools, by David & Traina Hawley

VBA and Macros for Microsoft Excel 2007, by Bill Jelen "Mr.Excel" and Tracy Syrstad

Excel 2007 Book: you can try this...there is a try before you buy ebook available at this link…
http://www.mrexcel.com/learnexcel2.shtml 

DonkeyOte: My Recommended Reading:

Volatility
http://www.decisionmodels.com/calcsecretsi.htm

Sumproduct
http://www.xldynamic.com/source/xld.SUMPRODUCT.html

Arrays
http://www.xtremevbtalk.com/showthread.php?t=296012

Pivot Intro
http://peltiertech.com/Excel/Pivots/pivotstart.htm

Email from XL - VBA
http://www.rondebruin.nl/sendmail.htm

Outlook VBA
http://www.outlookcode.com/article.aspx?ID=40

Function Dictionary
http://www.xlfdic.com/

Function Translations
http://www.piuha.fi/excel-function-name-translation/

Dynamic Named Ranges
http://www.contextures.com/xlNames01.html

And, as your skills increase, try answering posts on sites like:
http://www.mrexcel.com/
http://www.excelforum.com/
http://www.ozgrid.com/
http://www.vbaexpress.com/portal.php
http://p2p.wrox.com/excel-vba-79/


Where to paste code in VBE VBA
Introducing the Excel VBA Editor
http://www.ask.com/web?qsrc=2417&o=1...cel+VBA+Editor

VBA for Excel (Macros)
http://www.excel-vba.com/excel-vba-contents.htm

VBA Lesson 11: VBA Code General Tips and General Vocabulary
http://www.excel-vba.com/vba-code-2-1-tips.htm

Excel VBA -- Adding Code to a Workbook
http://www.contextures.com/xlvba01.html 

Explanation and Examples of VBA
http://www.beyondtechnology.com/vba.shtml

Training for Excel, Access, VBA, with free downloads and course notes
http://www.fontstuff.com/excel/index.htm

VBA samples for Excel and outlook, couple of video tutorials

http://www.codeforexcelandoutlook.com

More VBA samples
http://msmvps.com/blogs/nateoliver

Simple short VBA for beginners with explanations
http://www.angelfire.com/biz7/julian_s/julian/julians_macros.htm#J
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,214
Members
449,074
Latest member
cancansova

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