Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
ben ben is offline
external usenet poster
 
Posts: 22
Default find and replace issue in macro

Hello,

I have a macro in Excel 2007 where I do a copy from one spreadsheet file and
special paste to another sheet in another file. This works fine and it was
created by recording a macro and then doing some minor modifications. I
wanted to then do a find and replace where I make certain rows bold and a
different color, so I recorded another macro to see what it did so I could
insert the relevant code into my original macro. I did that but the results
when using the macro change the size of the text, making it smaller. If I
then go into format cells and the text tab everything looks fine. I then
click on the font size to another size and then immediately back to the
original size it was already on and click ok and it rights itself. I am
wondering though why this has to be done to begin with - i.e. why does the
font size change?

Here's the macro:
Selection.Copy
Windows("finances_2008.xlsx").Activate
Sheets("Spending").Select

ActiveCell.Offset(0, -1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

With Application.ReplaceFormat.Font
.FontStyle = "Bold"
.Subscript = False
.ThemeColor = 4
.TintAndShade = -0.249977111
End With
Selection.Replace What:="AMEX", Replacement:="AMEX", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=True

ActiveCell.Offset(0, 5).Select

Any help would be appreciated.
Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 11,058
Default find and replace issue in macro

This is only a guess, but make sure that ShrinkToFit is set to false.
--
Gary''s Student - gsnu2007k


"ben" wrote:

Hello,

I have a macro in Excel 2007 where I do a copy from one spreadsheet file and
special paste to another sheet in another file. This works fine and it was
created by recording a macro and then doing some minor modifications. I
wanted to then do a find and replace where I make certain rows bold and a
different color, so I recorded another macro to see what it did so I could
insert the relevant code into my original macro. I did that but the results
when using the macro change the size of the text, making it smaller. If I
then go into format cells and the text tab everything looks fine. I then
click on the font size to another size and then immediately back to the
original size it was already on and click ok and it rights itself. I am
wondering though why this has to be done to begin with - i.e. why does the
font size change?

Here's the macro:
Selection.Copy
Windows("finances_2008.xlsx").Activate
Sheets("Spending").Select

ActiveCell.Offset(0, -1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

With Application.ReplaceFormat.Font
.FontStyle = "Bold"
.Subscript = False
.ThemeColor = 4
.TintAndShade = -0.249977111
End With
Selection.Replace What:="AMEX", Replacement:="AMEX", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=True

ActiveCell.Offset(0, 5).Select

Any help would be appreciated.
Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.newusers
ben ben is offline
external usenet poster
 
Posts: 22
Default find and replace issue in macro

I checked after running the macro and the shrintofit box was unchecked.
When I change ReplaceFormat:=True to ReplaceFormat:=False, it doesn't happen
but then I also lose the formatting.


Gary''s Student wrote:
This is only a guess, but make sure that ShrinkToFit is set to false.

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
Macro to Find & Replace [email protected] Excel Worksheet Functions 2 September 14th 06 07:17 PM
Macro: Find and replace Bertie Excel Discussion (Misc queries) 1 May 29th 06 02:01 PM
Find & Replace in VB macro JackC Excel Discussion (Misc queries) 1 August 24th 05 09:22 PM
Excel find and replace issue buddyorliz Excel Discussion (Misc queries) 3 June 4th 05 09:51 PM
Excel find and replace issue buddyorliz Excel Discussion (Misc queries) 2 June 4th 05 04:14 PM


All times are GMT +1. The time now is 04:59 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"