Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Applying formula to entire column 1

Status
Not open for further replies.

emfraser

Materials
Aug 8, 2003
5
US
I'm trying to get an Excel macro to apply a formula to an entire column. I have a machine that exports an entire column of the exact time each step was performed. To make comparisons between runs, I would rather this act as a counter. So, I created a simple formula to make a new column that subtracts the first time recording from each subsequent cell. (for example, if the time is stored in column B, the formula is =$B2-$B$2 where B2 is the first time recorded.) I then want this formula filled all the way down the column, but only for the number of rows in column B. The number of rows changes every day. At the moment, I can only get the macro to apply the formula to a set number of rows. Does anybody know how to get the macro to only copy the formula down for however many rows are present in the other column? I can't have it do too many (my first instinct) because I want to graph the results and then the rest of the columns won't be the same length. Any ideas? Thanks!
 
Replies continue below

Recommended for you

Can try this - perhaps crude but works!

Sub test()
currentrow = 2
chck = 1
Do While chck = 1
Cells(currentrow, "C").Formula="=$B"&CStr(currentrow)&"-$B$2"
currentrow = currentrow + 1
If Cells(currentrow, "B").Value = 0 Then chck = 0
Loop
End Sub
 
Mutt --

Thanks so much! That worked like a charm! Thanks for saving my project!

--Eric
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top