How to auto-select within a macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I recorded the following simple macro to check for a problem in some columns
on a worksheet I'm working on daily.

Selection.Replace What:=".988", Replacement:=".99", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub

However, there are some additional common problems I would like to take care
of, and I thought of chaining several similar macros (essentially just
changing the values for "what" and "replacement") so that in the end, I'll be
able to click one button to check for all of them.

What I am wondering is how to specify particular columns, and also the
entire sheet, in a macro. Some of the potential problems I'm trying to catch
can occur anywhere on the sheet, whereas others are only an issue in certain
columns. Applying that fix to other columns could have undesirable results.

Thank you.
 
Let's say you want the macro to work on column C

Replace

Selection.

with

columns("C").

To act on the entire worksheet use

cells().
 
It's that simple? Sweet.
How do I specify several columns?

Columns("c","d","e")? Or columns ("c"), ("d"), ("e")? Or something
completely different?
 
Just out of curiosity - do you really need the ""? It seems to be working
without, but maybe there's a good reason to add those?
 
Back
Top