A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Macro: Insert formula for each row of data



 
 
Thread Tools Display Modes
  #1  
Old August 18th, 2011, 01:11 AM
Jeff Monroe Jeff Monroe is offline
Member
 
First recorded activity by OfficeFrustration: May 2006
Location: San Diego, CA
Posts: 27
Default Macro: Insert formula for each row of data

I have a variable sized data set in a work sheet. Simplified it's like this:

A B
1 data1 =Today()
2 data2 =Today()
3 data3 =Today()

(Column A lists rows of data, Column B I want to insert today's date for each row)



I have a series of macros that reformat the worksheet dataset and I want to tack on the "Today's Date" formula for each record without going past the lastrow (of column A). The number of rows varies each time I import the record set. What I'm doing now is copying the formula (from Row 1) and pasting itinto a number of records I know exceeds the total of record rows imported. I then go back and delete those extra rows. (I do this for several other columns with different functions).

I know there is a better way.

Thanks.

Jeff
__________________
jm

Last edited by Jeff Monroe : August 18th, 2011 at 05:07 AM.
  #2  
Old August 18th, 2011, 04:50 PM
tarquinious tarquinious is offline
Experienced Member
 
First recorded activity by OfficeFrustration: Mar 2011
Posts: 34
Default

You could use something like:
Code:
=IF(A2="","",TODAY())
In this way it doesn't matter if you paste it further than the data you have, nothing will appear if there is no data in the cell.
  #3  
Old August 23rd, 2011, 12:52 AM
Jeff Monroe Jeff Monroe is offline
Member
 
First recorded activity by OfficeFrustration: May 2006
Location: San Diego, CA
Posts: 27
Default

Quote:
Originally Posted by tarquinious View Post
You could use something like:
Code:
=IF(A2="","",TODAY())
In this way it doesn't matter if you paste it further than the data you have, nothing will appear if there is no data in the cell.

Tarquinos:
That formula works. The only problem is there is now information in those cells. Because of that, those rows are included in any sorts I do (unless I filter out the blanks). This actually pushes some of my filled rows down to the last rows of 2000 (text comes after blanks). I would like to figure out how to do a loop based on how many records I have.

Thanks.
__________________
jm
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:35 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.