LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Write a macro to populate a column with a formula

I suspect this is an elementary concept for VBA, hopefully this will b
an easy answer for y'all:
I would like to write a macro that populates a cell with a formul
given a certain condition is met in another cell. I setup a pivot tabl
that imports pertinent data from a master table. One column contain
the trigger info - an "M" means that we do not want the formula to b
imported otherwise we do want it. the column containing the trigge
will not move, likewise the destination formula will not move (no fanc
offsets required). I simply want the macro to recognize a non-"M" i
cell D4 and put my formula in F4.

The pivot table will constantly be updating, the "M"s and othe
characters (always integers if not M) in the target column (D) will b
changing. When an M shows up, the spreadsheet user will have t
manually enter data into the F column, which would overwrite a stati
entry if we were to simply write a formula.

I am not quite sure how to make the leap to scanning all the rows of m
document. I changed each of the ranges to (D4:D10), (F4:F10
respectively but when I run the macro I get the error "type mismatch"


Here's my code:
--------------------------------------------------------------------------------
Sub y_1()
If Range("D4:D10").Value < "M" Then
Range("F4:F10").Formula = "=D4+1"
Else
Range("F4:F10").Value = ""
End If
End Sub
--------------------------------------------------------------------------------



Thank you in advance for any help you might be able to give

--
Message posted from http://www.ExcelForum.com

 
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
Use macro to write formula nc Excel Discussion (Misc queries) 1 July 5th 09 07:13 AM
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? Daniel Excel Worksheet Functions 1 June 23rd 05 11:38 PM
Write formula to add "1" to each number in a column GrannyLib Excel Worksheet Functions 3 January 11th 05 07:09 PM
How to populate column with formula based on value in cell Cameron Stewart Excel Worksheet Functions 2 November 2nd 04 01:36 AM
Write a macro ro copy column at certain time of day. Daytrader Excel Programming 2 February 2nd 04 05:28 AM


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