Macro Issue

awappel

New Member
Joined
Mar 15, 2011
Messages
14
I have a macro that I am using that is supposed to copy a formula down an entire column. When I wrote the macro I did a scrolling copy downt he column to get the formula in each cell. I am getting an error that says "Run-time error '1004': Unable to se the ScrollRow property of the Window class" when I run the macro. Is there another way to copy down a formula that would work better in the Macro?
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
You can add a formula to a column all in one go like this:

Code:
Range("C1:C100").Formula="=A1+B1"
 
Upvote 0
Hi and welcome to the board!!!

What Column are you is the formula in and how do you determine how far down??

lenze
 
Upvote 0
I am using Column E, and I just had scrolled down to about 20 rows lower than my last data. So no really good process of determiing how far down I need to go.
 
Upvote 0
Try like this - change the formula to suit

Code:
Sub Test2()
Dim LR As Long
LR = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
Range("E1:E" & LR).Formula = "=A1+B1"
End Sub
 
Upvote 0
Assumming you have data in Column "A" and you want to copy down to the last row occupied, you can use something like this
Code:
Sub AddFormula()
Dim LR As Long
LR = Cells(Rows.Count, "A").End(xlUp).Row
Range("$E$2:E" & LR).Formula = "=C2+D2"
End Sub

lenze
 
Upvote 0
Sub Test2()
Dim LR As Long
LR = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
Range("E1:E" & LR).Formula = "=CONCATENATE(B2," ",D2," ",C2)"
End Sub

Above is what I used, but it is telling me that the " " are causing expected end to the function or syntax error. I am just out of lunch because the Concantenate uses " "?
 
Upvote 0
Try

Code:
Sub Test2()
Dim LR As Long
LR = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
Range("E1:E" & LR).Formula = "=CONCATENATE(B2,"" "",D2,"" "",C2)"
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,671
Members
452,937
Latest member
Bhg1984

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