PC Review


Reply
Thread Tools Rate Thread

How to auto-select within a macro

 
 
=?Utf-8?B?TmluaWVs?=
Guest
Posts: n/a
 
      20th Aug 2007
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.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?RHVrZSBDYXJleQ==?=
Guest
Posts: n/a
 
      20th Aug 2007
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().


"Niniel" wrote:

> 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.

 
Reply With Quote
 
=?Utf-8?B?TmluaWVs?=
Guest
Posts: n/a
 
      20th Aug 2007
It's that simple? Sweet.
How do I specify several columns?

Columns("c","d","e")? Or columns ("c"), ("d"), ("e")? Or something
completely different?


 
Reply With Quote
 
=?Utf-8?B?RHVrZSBDYXJleQ==?=
Guest
Posts: n/a
 
      20th Aug 2007
Use:

columns("C:E")

"Niniel" wrote:

> It's that simple? Sweet.
> How do I specify several columns?
>
> Columns("c","d","e")? Or columns ("c"), ("d"), ("e")? Or something
> completely different?
>
>

 
Reply With Quote
 
=?Utf-8?B?TmluaWVs?=
Guest
Posts: n/a
 
      20th Aug 2007
Never mind, I figured it out: (c:e).

Thanks a lot, Duke, that was very helpful!
 
Reply With Quote
 
=?Utf-8?B?TmluaWVs?=
Guest
Posts: n/a
 
      20th Aug 2007
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?
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to select cells without a certain value and select a menu it Guy Microsoft Excel Worksheet Functions 9 2nd Jan 2009 05:21 PM
Macro to select files and then run different macro on selected file beginner1.mat@hotmail.com Microsoft Excel Programming 5 31st Jan 2008 03:39 AM
Auto-run macro after auto-query refresh (Excel2000,sr1) =?Utf-8?B?QmlsbCBDdWZmbGlu?= Microsoft Excel Programming 3 29th Jun 2006 03:30 AM
Auto Name Checking should auto select EMAIL and not display FAX =?Utf-8?B?U2xvb3BlcjI=?= Microsoft Outlook Discussion 0 4th Jan 2006 07:00 PM
Select other workbook to select data in a macro. T Tromp Microsoft Excel Programming 2 19th Sep 2003 01:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:19 PM.