×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Applying formula to entire column

Applying formula to entire column

Applying formula to entire column

(OP)
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!

RE: Applying formula to entire column

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

RE: Applying formula to entire column

(OP)
Mutt --

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

--Eric

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources