Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I want to copy the formula in E7 down to the number of rows that contain data in columns A through D. But this number may vary. In this example the last row with data will be 12,073. How can I get VBA to take this into account? Range("E7").Formula = "=Sum(B7:D7)" Range("E7").Copy Destination:=oWorksheet.Range("E8:E12073") |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi AM
This example will filldown till the last value in D Sub test() Dim LastRow As Long With Worksheets("Sheet2") .Range("E7").Formula = "=Sum(B7:D7)" LastRow = .Cells(Rows.Count, "D").End(xlUp).Row .Range("E7").AutoFill Destination:=.Range("E7:E" & LastRow) _ , Type:=xlFillDefault End With End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "AM" wrote in message ... I want to copy the formula in E7 down to the number of rows that contain data in columns A through D. But this number may vary. In this example the last row with data will be 12,073. How can I get VBA to take this into account? Range("E7").Formula = "=Sum(B7:D7)" Range("E7").Copy Destination:=oWorksheet.Range("E8:E12073") |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dim rng as Range
set rng = cells(rows.count,4).End(xlup)(1,2) Range(range("E7"),rng).Formula = "=Sum(B7:D7)" as an example in the immdiate window: set rng = cells(rows.count,4).End(xlup)(1,2) ? range(range("E7"),rng).Address $E$7:$E$20 -- Regards, Tom Ogilvy "AM" wrote in message ... I want to copy the formula in E7 down to the number of rows that contain data in columns A through D. But this number may vary. In this example the last row with data will be 12,073. How can I get VBA to take this into account? Range("E7").Formula = "=Sum(B7:D7)" Range("E7").Copy Destination:=oWorksheet.Range("E8:E12073") |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Can't Copy and Paste or Paste Special between Excel Workbooks | Excel Discussion (Misc queries) | |||
Copy; Paste; Paste Special are disabled | Excel Discussion (Misc queries) | |||
Excel cut/Paste Problem: Year changes after data is copy and paste | Excel Discussion (Misc queries) | |||
I cannot paste from one workbook to another. Copy works, paste do. | Excel Discussion (Misc queries) | |||
Macro to Copy/Paste then Paste to Next Line | Excel Programming |