Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 80
Default How to auto-select within a macro

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.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,081
Default How to auto-select within a macro

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.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 80
Default How to auto-select within a macro

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

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


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,081
Default How to auto-select within a macro

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?


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 80
Default How to auto-select within a macro

Never mind, I figured it out: (c:e).

Thanks a lot, Duke, that was very helpful!


  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 80
Default How to auto-select within a macro

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Range Select C Brandt Excel Discussion (Misc queries) 1 May 21st 07 09:29 PM
auto word select jimmy Excel Discussion (Misc queries) 1 April 25th 05 01:17 PM
Auto Word Select jimmy Excel Discussion (Misc queries) 0 April 25th 05 11:19 AM
Auto Word Select jimmy Excel Discussion (Misc queries) 0 April 25th 05 11:19 AM
auto word select jimmy Excel Discussion (Misc queries) 0 April 25th 05 11:07 AM


All times are GMT +1. The time now is 04:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"