Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Pain in the ass macro


Im working on a macro that will go throgh an entire spreadsheet and tak
out the "XXXX" in the formulas and replace it with a year giving me th
ability to create a report for any year. As of right now the only wa
it will work is if I hardcode an actual year such as 2005 because th
find and replace I am running wont let me put a cell in the replac
secton instead of a defined number.

Cells.Replace What:="XXXX", Replacement:="2005", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

That is the macro code for the find and replace secton, what i need t
do is replace the "2005" with a cell link so that before I run the macr
I can insert any year I want into that cell and then run the macr
giving me a report for any year I want. If its any help at all the cel
that the user inputs the year is L2, so some how 2005 must change to
link to L2. Ive been messing with this for hours but nothing ha
worked.

I would greatly appreciate any help at all. Thank yo

--
Jesse
-----------------------------------------------------------------------
JesseK's Profile: http://www.excelforum.com/member.php...fo&userid=2496
View this thread: http://www.excelforum.com/showthread.php?threadid=38492

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Pain in the ass macro

Creat a variable and use it instead of "2005"
myvariable = ?????

Cells.Replace What:="XXXX", Replacement:="2005",

Cells.Replace What:="XXXX", Replacement:=myvariable,

--
steveB

Remove "AYN" from email to respond
"JesseK" wrote in
message ...

Im working on a macro that will go throgh an entire spreadsheet and take
out the "XXXX" in the formulas and replace it with a year giving me the
ability to create a report for any year. As of right now the only way
it will work is if I hardcode an actual year such as 2005 because the
find and replace I am running wont let me put a cell in the replace
secton instead of a defined number.

Cells.Replace What:="XXXX", Replacement:="2005", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

That is the macro code for the find and replace secton, what i need to
do is replace the "2005" with a cell link so that before I run the macro
I can insert any year I want into that cell and then run the macro
giving me a report for any year I want. If its any help at all the cell
that the user inputs the year is L2, so some how 2005 must change to a
link to L2. Ive been messing with this for hours but nothing has
worked.

I would greatly appreciate any help at all. Thank you


--
JesseK
------------------------------------------------------------------------
JesseK's Profile:
http://www.excelforum.com/member.php...o&userid=24964
View this thread: http://www.excelforum.com/showthread...hreadid=384924



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Pain in the ass macro

Hi,

Cells.Replace What:="XXXX", Replacement:=Range("L2"), LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False


HTH

"JesseK" wrote:


Im working on a macro that will go throgh an entire spreadsheet and take
out the "XXXX" in the formulas and replace it with a year giving me the
ability to create a report for any year. As of right now the only way
it will work is if I hardcode an actual year such as 2005 because the
find and replace I am running wont let me put a cell in the replace
secton instead of a defined number.

Cells.Replace What:="XXXX", Replacement:="2005", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

That is the macro code for the find and replace secton, what i need to
do is replace the "2005" with a cell link so that before I run the macro
I can insert any year I want into that cell and then run the macro
giving me a report for any year I want. If its any help at all the cell
that the user inputs the year is L2, so some how 2005 must change to a
link to L2. Ive been messing with this for hours but nothing has
worked.

I would greatly appreciate any help at all. Thank you


--
JesseK
------------------------------------------------------------------------
JesseK's Profile: http://www.excelforum.com/member.php...o&userid=24964
View this thread: http://www.excelforum.com/showthread...hreadid=384924


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Pain in the ass macro

You can have the same effect with no macro needed at all. Choose the cell
where you want to put the year and give the cell a name - call it something
like ReportYear. Then do your find and replace (manually, just this once)
and replace your "XXXX" with "ReportYear". Now the formulas all refer to the
contents of that cell and as soon as you change the cell the formulas should
update.

"JesseK" wrote:


Im working on a macro that will go throgh an entire spreadsheet and take
out the "XXXX" in the formulas and replace it with a year giving me the
ability to create a report for any year. As of right now the only way
it will work is if I hardcode an actual year such as 2005 because the
find and replace I am running wont let me put a cell in the replace
secton instead of a defined number.

Cells.Replace What:="XXXX", Replacement:="2005", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

That is the macro code for the find and replace secton, what i need to
do is replace the "2005" with a cell link so that before I run the macro
I can insert any year I want into that cell and then run the macro
giving me a report for any year I want. If its any help at all the cell
that the user inputs the year is L2, so some how 2005 must change to a
link to L2. Ive been messing with this for hours but nothing has
worked.

I would greatly appreciate any help at all. Thank you


--
JesseK
------------------------------------------------------------------------
JesseK's Profile: http://www.excelforum.com/member.php...o&userid=24964
View this thread: http://www.excelforum.com/showthread...hreadid=384924


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Pain in the ass macro


Hi Jesse,


To stop your pain, (in that part) you could use this:


Code
-------------------
Cells.Replace What:="XXXX", Replacement:=Range("L2"), LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=Fals
-------------------


Hope this reliefs your soul.:)


Best Regards

Jose Luis

JesseK Wrote:
Im working on a macro that will go throgh an entire spreadsheet and tak
out the "XXXX" in the formulas and replace it with a year giving me th
ability to create a report for any year. As of right now the only wa
it will work is if I hardcode an actual year such as 2005 because th
find and replace I am running wont let me put a cell in the replac
secton instead of a defined number.

Cells.Replace What:="XXXX", Replacement:="2005", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

That is the macro code for the find and replace secton, what i need t
do is replace the "2005" with a cell link so that before I run the macr
I can insert any year I want into that cell and then run the macr
giving me a report for any year I want. If its any help at all the cel
that the user inputs the year is L2, so some how 2005 must change to
link to L2. Ive been messing with this for hours but nothing ha
worked.

I would greatly appreciate any help at all. Thank yo


--
jose lui
-----------------------------------------------------------------------
jose luis's Profile: http://www.excelforum.com/member.php...fo&userid=1331
View this thread: http://www.excelforum.com/showthread.php?threadid=38492



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Pain in the ass macro


Thank you so much, it worked perfectly.


--
JesseK
------------------------------------------------------------------------
JesseK's Profile: http://www.excelforum.com/member.php...o&userid=24964
View this thread: http://www.excelforum.com/showthread...hreadid=384924

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
Task Pain tc Excel Discussion (Misc queries) 4 August 29th 07 04:44 PM
Comments on frozen pain Flints Excel Discussion (Misc queries) 2 August 8th 06 04:41 PM
Oh God the Pain! Help Please! jshpik1 Excel Discussion (Misc queries) 2 May 9th 06 08:25 AM
pain cell max and min [email protected] Excel Programming 2 March 31st 05 10:26 AM
Pivot Table Pain! Alastair MacFarlane Excel Programming 2 February 22nd 04 03:59 PM


All times are GMT +1. The time now is 12:16 AM.

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

About Us

"It's about Microsoft Excel"