Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Formula in code

OK i have a formula that pulls from two different sheets. If one of the
sheets is not there I get the #REF! error which i get why. Where im stuck is
which ever sheet is not there i need to adjust the formula so that it will
then only pull from the one sheet. I just cant think of how to do this in
code.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200707/1

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Formula in code

Please show your formula.

"jln via OfficeKB.com" wrote:

OK i have a formula that pulls from two different sheets. If one of the
sheets is not there I get the #REF! error which i get why. Where im stuck is
which ever sheet is not there i need to adjust the formula so that it will
then only pull from the one sheet. I just cant think of how to do this in
code.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200707/1


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Formula in code

Dim cell as Range

if cell.Text = "#REF!" then
s = cell.Formula
if instr(1,cell.formula,"Sheet1",vbTextCompare) then
s = Replace(s,"Sheet1","Sheet2")
else
s = Replace(s,"Sheet2","Sheet1")
end if
cell.Formula = s
End if

--
Regards,
Tom Ogilvy


"jln via OfficeKB.com" wrote:

OK i have a formula that pulls from two different sheets. If one of the
sheets is not there I get the #REF! error which i get why. Where im stuck is
which ever sheet is not there i need to adjust the formula so that it will
then only pull from the one sheet. I just cant think of how to do this in
code.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200707/1


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
Need formula or code Sandy Excel Programming 9 April 13th 06 02:14 PM
Help with Formula in Code Juan Excel Programming 1 March 27th 06 06:36 PM
Code or Formula? Oggie Ben Doggie Excel Programming 4 November 16th 05 04:58 PM
Help with my code and formula yh73090[_2_] Excel Programming 1 August 30th 04 06:06 AM
formula to code help JohnE Excel Programming 2 February 28th 04 01:27 AM


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