ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using VBA to Insert Formula in Copied Sheet (https://www.excelbanter.com/excel-programming/358033-using-vba-insert-formula-copied-sheet.html)

Rich Kniatt

Using VBA to Insert Formula in Copied Sheet
 

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

--
Rich Kniat
-----------------------------------------------------------------------
Rich Kniatt's Profile: http://www.excelforum.com/member.php...fo&userid=1909
View this thread: http://www.excelforum.com/showthread.php?threadid=52983


Don G

Using VBA to Insert Formula in Copied Sheet
 
Hi Rich,

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

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

"Rich Kniatt" wrote:


This should be easy for the gurus out there.

I have a snippet of code that needs to contain something similar to
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"


--
Rich Kniatt
------------------------------------------------------------------------
Rich Kniatt's Profile: http://www.excelforum.com/member.php...o&userid=19093
View this thread: http://www.excelforum.com/showthread...hreadid=529834



Tom Ogilvy

Using VBA to Insert Formula in Copied Sheet
 
Range("j15:J34").Formula = "=c15*I15"

--
Regards,
Tom Ogilvy



"Rich Kniatt" wrote
in message ...

This should be easy for the gurus out there.

I have a snippet of code that needs to contain something similar to
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"


--
Rich Kniatt
------------------------------------------------------------------------
Rich Kniatt's Profile:

http://www.excelforum.com/member.php...o&userid=19093
View this thread: http://www.excelforum.com/showthread...hreadid=529834




Rich Kniatt[_3_]

Using VBA to Insert Formula in Copied Sheet
 

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

Tom Ogilvy Wrote:
Range("j15:J34").Formula = "=c15*I15"

--
Regards,
Tom Ogilvy



"Rich Kniatt"
wrote
in message
...

This should be easy for the gurus out there.

I have a snippet of code that needs to contain something similar to
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"


--
Rich Kniatt

------------------------------------------------------------------------
Rich Kniatt's Profile:

http://www.excelforum.com/member.php...o&userid=19093
View this thread:

http://www.excelforum.com/showthread...hreadid=529834



--
Rich Kniatt
------------------------------------------------------------------------
Rich Kniatt's Profile: http://www.excelforum.com/member.php...o&userid=19093
View this thread: http://www.excelforum.com/showthread...hreadid=529834



All times are GMT +1. The time now is 04:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com