LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
Ed Ed is offline
external usenet poster
 
Posts: 279
Default Insert a Formula with a Macro

Hello I have the following macro but I would like to rather than insert the
value to insert a IF formula:

Dim LastRow As Long
LastRow = Worksheets("Sheet A").Range("O2")
Sheets("Registry").Select
Range("B" & LastRow) = "=Row(B" & LastRow - 1 & ")"
Range("C" & LastRow) = Worksheets("Sheet A").Range("K2")
Range("D" & LastRow) = Worksheets("Sheet A").Range("K12")

For the 2 last lines, I would like that instead of inserting values K2 and
K12, I would like to insert a IF formula on Sheet "Registry"

=IF(A&LastRow="X","-",Worksheets("Sheet A").Range("K2"))

substituting with the values would give things like in the cell.

(LastRow = 6)

For C6 =IF(A6="X","-","13500")
For D6 =IF(A6="X","-","21/Oct/06")

and so on...

thanks!

 
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 insert formula nobbyknownowt Excel Worksheet Functions 3 June 28th 06 05:16 PM
Dynamic column insert (macro) Chris Excel Discussion (Misc queries) 2 March 15th 06 11:33 AM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
Formula for current month minus one = Quarter number in a macro. Pank Excel Discussion (Misc queries) 11 June 22nd 05 02:47 PM
Insert Line Macro Spyder Excel Discussion (Misc queries) 1 March 3rd 05 12:17 AM


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