Using VBA to Insert Formula in Copied Sheet

  • Thread starter Thread starter Rich Kniatt
  • Start date Start date
R

Rich Kniatt

This should be easy for the gurus out there.

I have a snippet of code that needs to contain something similar t
below but carry through J34. Is there a way to do this with one line?

Range("j15").Formula = "=c15*I15"
Range("j16").Formula = "=c16*I16"
Range("j17").Formula = "=c17*I17
 
Hi Rich,

Here's a code that works although there's probably a better solution out
there somewhere:

Sub test()

Dim x As Integer
x = 15

Start:
If x = 35 Then Exit Sub
Range("J" & x).Formula = "=C" & x & "*I" & x
x = x + 1
GoTo Start

End Sub

Adjust x to fit your start cell and adjust the If statement to fit one past
your ending cell. HTH

Don
 
Thanks Tom, it seems the easiest way is not always the most obvious ;)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top