Copying Formulas to Multiple Rows

fb250r

Board Regular
Joined
Apr 25, 2002
Messages
104
Book2
ABCDEFGHIJKLMNO
1IndexSite_IDNgbr_List#ofNgbrsGridsCommentDistanceAway(mi)Site_ID#ofNgbrsNgbr_List
20AD60551771.35177930.6964921ADAM6016
31AD69037691.35254050.69524120.00138054.74586328.78933865.5ADAM6016ADAM690
42CU0419831.35699790.69897560.004707416.18288629.97070418.6ADAM6016CUMB04
53YO3516071.35095950.69793440.00157335.408640810.0168036.2ADAM6016YORK35
64CU0214831.36025630.69723620.006543122.4934741.65790725.9ADAM6016CUMB02
75FK025391.35528640.70067730.004972817.09509931.66012219.7ADAM6016FRAN02
80AD69047913ADAM69016
91AD604295ADAM69016ADAM60
102CU043174ADAM69016CUMB04
113CU023010ADAM69016CUMB02
124YO352564ADAM69016YORK35
130AL25212589ALLE2516
141WS035637ALLE2516WEST03
152AL643839ALLE2516ALLE64
Sheet1


Columns G- L contain formulas that I want to paste down, but the blocks of data have varying row counts. I know I can just select the given number of rows and paste what I need, but I have so many rows to paste down to.


For Example:
B2 is a block of data with 6 rows associated to it. B8 has 5 rows of formulas. B13 has 3 rows of formulas.

I need to populate only the rows that are blank with formulas from the B2 thru Lxx.

I can copy manually, but I have quite a few rows and blocks. What I have been doing is copying and pasting one less row as I go down the list.

This may be a doozie!


Frank
(y)
 
Frank, how about this code:
Code:
Sub CopyFormula()
'Written by Barrie Davidson

Dim DataRange As Range
Dim CopyRange As Range

Application.ScreenUpdating = False
Set DataRange = Range("A8:A" & Range("A65536").End(xlUp).Row)
Set CopyRange = Range("G2:L2")
For Each c In DataRange
    CopyRange.Offset(c.Value).Copy _
        Destination:=c.Offset(0, 6)
Next c
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Hey Barrie,

I was just visiting your web page on VBA and Excel formulas. Nice Job!

I'll let you know how it turns out.

Forever grateful,

Frank
 
Upvote 0
Barrie,

You ROCK, my Canadian Friend!

I hope I can return the favor one day or help anyone else in need.

Kind Regards,

Frank
:pray: & (y)
 
Upvote 0
Barrie,

I tried to change the Data Range from 65565 to a smaller number like, 10,000 so that the program will execute faster and I get a RunTime error "13".

Any ideas?

Regards,

Frank
 
Upvote 0
Barrie Davidson wrote this great code for me but it needs a minor revision that I cannot seem to correct.

I would like the code to end its search for data based on the last used cell in Column A. Currently it searches down to A65565 and it takes to darn long.



Does anyone have any ideas?

Frank
 
Upvote 0
Hi Frank:

In Barrie's code after the line ...

For Each c In DataRange

add

if c = "" then exit sub

Does it help?
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,715
Members
448,985
Latest member
chocbudda

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top