LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 43
Default How do I add a formula to a macro?

Could anyone helping me with this?

After deleting column A & B, adding 2 column G and H and enter text in G2
and H2, Id like to add a formula G2 (as well as H2). How do I add formula
to a macro?

Formula on G2: =IF(I2="0001", "E?", IF(OR(I2="0002", I2="0003",
I2="0004", I2="0005"), "Y", "N"))
Formula on H2: =IF(A2<A3,"Row used")

As following is the VBA codes for my macro:
Sub CompFormula()
'
' CompFormula Macro

Columns("H:H").ColumnWidth = 12.14
Columns("A:B").Select
Selection.Delete Shift:=xlToLeft
Columns("G:H").Select
Selection.Insert Shift:=xlToRight
Range("G1").Select
ActiveCell.FormulaR1C1 = "Meet Y/N"
Range("H1").Select
ActiveCell.FormulaR1C1 = "Row used"
Range("G2").Select
End SubSub CompFormula()

--
Thanks,
Aline
 
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
Formula - Macro orquidea Excel Discussion (Misc queries) 7 December 7th 07 02:19 AM
Is there a Formula or Macro for This? Marilyn Excel Discussion (Misc queries) 8 May 7th 07 05:03 PM
set formula by Macro [email protected] Excel Worksheet Functions 3 December 1st 06 02:02 PM
Help with macro or formula JAZZNAURA Excel Discussion (Misc queries) 0 August 18th 06 08:41 AM
Add formula to Macro??? [email protected] New Users to Excel 3 July 9th 06 02:29 PM


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