Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default How do I convert a Formula into Code???

Hi there,

I have a problem, I have various formulas that I use within my worksheet,
however when I update the sheet where the formulas reference I get #REF
errors all the time. This really isn't a problem as I go into the formulas
and change them so that they are okay. However I would really like to
convert the formulas to code, so that when I run a macro the formulas are
inserted into a specified cell.
The formulas are as follow =IF(COUNTIF('1103 Working Sheet Last
Week'!A:A,'1103 Working Sheet'!A2)=0,'1103 Working Sheet'!A2,"") which I
would like to go into cell B3 and the following formula I would like to go
into cell D1 =VLOOKUP(B1,'1103 Working Sheet'!$A$2:$B$1500,2,FALSE) using
code.

regards Harry


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How do I convert a Formula into Code???

Option Explicit
Sub testme()
With ActiveSheet
.Range("b3").Formula _
= "=IF(COUNTIF('1103 Working Sheet Last Week'!A:A," _
& "'1103 Working Sheet'!A2)=0,'1103 Working Sheet'!A2,"""")"
.Range("D1").Formula _
= "=VLOOKUP(B1,'1103 Working Sheet'!$A$2:$B$1500,2,FALSE)"
End With
End Sub

Lot's of times you can record a macro when you do the work and you'll get the
code you need.



BigH wrote:

Hi there,

I have a problem, I have various formulas that I use within my worksheet,
however when I update the sheet where the formulas reference I get #REF
errors all the time. This really isn't a problem as I go into the formulas
and change them so that they are okay. However I would really like to
convert the formulas to code, so that when I run a macro the formulas are
inserted into a specified cell.
The formulas are as follow =IF(COUNTIF('1103 Working Sheet Last
Week'!A:A,'1103 Working Sheet'!A2)=0,'1103 Working Sheet'!A2,"") which I
would like to go into cell B3 and the following formula I would like to go
into cell D1 =VLOOKUP(B1,'1103 Working Sheet'!$A$2:$B$1500,2,FALSE) using
code.

regards Harry


--

Dave Peterson
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
How to convert cell formula functions to code functions Adnan Excel Discussion (Misc queries) 1 October 1st 08 08:30 PM
Convert a Number Code to a Text Code Traye Excel Discussion (Misc queries) 3 April 6th 07 09:54 PM
UDF to convert data to code 128 B Safi Excel Worksheet Functions 0 July 30th 06 07:27 AM
vb help, convert from formula to vb code.. Michael A Excel Discussion (Misc queries) 1 January 7th 06 11:30 AM
Convert VBA code to VB.NET Sam Kelly. Excel Programming 0 November 18th 05 09:41 AM


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