ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy paste a formula in multiple cells (https://www.excelbanter.com/excel-programming/344677-copy-paste-formula-multiple-cells.html)

Vijaya

Copy paste a formula in multiple cells
 
I dont have consecutive cells ,I have cells like G3, G6, G9... uptil G500 or so
How should I copy paste a formula into these cells without manually
selecting all these cells using ctrl key

Is there a way to select these cells and copy paste the formula



tuvi

Copy paste a formula in multiple cells
 
Assuming that the cells are incrementing by 3.... and shCurrent is the name
of your worksheet in question. Here is the code:

Dim rSelect As Range
Dim strRange As String
Dim nRange As Integer

strRange = "G3"
For nRange = 6 To 500 Step 3
strRange = strRange & ",G" & nRange
Next nRange

Set rSelect = shCurrent.Range(strRange)
shCurrent.Cells(1, 1).Copy
rSelect.Select
shCurrent.Paste
Application.CutCopyMode = False

*** One Final Note: I test out the above and find that the 500 is too much
for Excel to handle. 174 is the limit. So I suggest that you divide into
chunks of 150-loop iterations. That is:
For nRange = 6 To 150 Step 3
For nRange = 153 To 300 Step 3
For nRange = 303 To 500 Step 3



"vijaya" wrote:

I dont have consecutive cells ,I have cells like G3, G6, G9... uptil G500 or so
How should I copy paste a formula into these cells without manually
selecting all these cells using ctrl key

Is there a way to select these cells and copy paste the formula




All times are GMT +1. The time now is 04:51 AM.

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