ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro to copy down formulas (https://www.excelbanter.com/excel-programming/354274-macro-copy-down-formulas.html)

pmarques[_5_]

macro to copy down formulas
 

I need a macro to copy down formulas. The expected macro should do the
following:
Ex: I select the cells with the formulas and call the macro
1- Asks (input) for the "final cells", I write ex J:14000;H1400
(the next time i call the macro should give by default the last one
incerted.)
2- Copy automatically the formula until the "final cells".

If someone can help me, please do
Thanks
:

--
pmarque
-----------------------------------------------------------------------
pmarques's Profile: http://www.excelforum.com/member.php...fo&userid=2511
View this thread: http://www.excelforum.com/showthread.php?threadid=51613


Bernie Deitrick

macro to copy down formulas
 
pmarques,

Try the macro below.

HTH,
Bernie
MS Excel MVP

Option Explicit
Dim myLastCell As Range

Sub TryNow()
If Not ActiveCell.HasFormula Then
MsgBox "You must select a cell(s) with a formula" _
& Chr(10) & "prior to running this macro."
Exit Sub
End If

If myLastCell Is Nothing Then
Set myLastCell = Application.InputBox("Last Cell?", _
Default:=ActiveCell.Address, Type:=8)
Else
Set myLastCell = Application.InputBox("Last Cell?", _
Default:=myLastCell.Address, Type:=8)
End If

Selection.Copy Range(Selection, myLastCell)
End Sub




"pmarques" wrote in message
...

I need a macro to copy down formulas. The expected macro should do the
following:
Ex: I select the cells with the formulas and call the macro
1- Asks (input) for the "final cells", I write ex J:14000;H14000
(the next time i call the macro should give by default the last ones
incerted.)
2- Copy automatically the formula until the "final cells".

If someone can help me, please do
Thanks
:)


--
pmarques
------------------------------------------------------------------------
pmarques's Profile: http://www.excelforum.com/member.php...o&userid=25110
View this thread: http://www.excelforum.com/showthread...hreadid=516130




pmarques[_8_]

macro to copy down formulas
 

*Very good!

Just one thing, it´s working with one single columm, it's possible
to
use de macro to work for example with two adjacent collums selected
(with diferent formulas)

Thanks a lot :)
:)*----------------------------------------------------------------------
Bernie Deitrick Wrote:
pmarques,

Try the macro below.

HTH,
Bernie
MS Excel MVP

Option Explicit
Dim myLastCell As Range

Sub TryNow()
If Not ActiveCell.HasFormula Then
MsgBox "You must select a cell(s) with a formula" _
& Chr(10) & "prior to running this macro."
Exit Sub
End If

If myLastCell Is Nothing Then
Set myLastCell = Application.InputBox("Last Cell?", _
Default:=ActiveCell.Address, Type:=8)
Else
Set myLastCell = Application.InputBox("Last Cell?", _
Default:=myLastCell.Address, Type:=8)
End If

Selection.Copy Range(Selection, myLastCell)
End Sub



--
pmarques
------------------------------------------------------------------------
pmarques's Profile: http://www.excelforum.com/member.php...o&userid=25110
View this thread: http://www.excelforum.com/showthread...hreadid=516130


Bernie Deitrick

macro to copy down formulas
 
pmarques,

It will work for multiple columns as written. Just select your two (or three or eight) cells with
formulas, then select your end cell appropriately, at the bottom of the second (or third or eighth)
column.

HTH,
Bernie
MS Excel MVP


"pmarques" wrote in message
...

*Very good!

Just one thing, it´s working with one single columm, it's possible
to
use de macro to work for example with two adjacent collums selected
(with diferent formulas)

Thanks a lot :)
:)*----------------------------------------------------------------------
Bernie Deitrick Wrote:
pmarques,

Try the macro below.

HTH,
Bernie
MS Excel MVP

Option Explicit
Dim myLastCell As Range

Sub TryNow()
If Not ActiveCell.HasFormula Then
MsgBox "You must select a cell(s) with a formula" _
& Chr(10) & "prior to running this macro."
Exit Sub
End If

If myLastCell Is Nothing Then
Set myLastCell = Application.InputBox("Last Cell?", _
Default:=ActiveCell.Address, Type:=8)
Else
Set myLastCell = Application.InputBox("Last Cell?", _
Default:=myLastCell.Address, Type:=8)
End If

Selection.Copy Range(Selection, myLastCell)
End Sub



--
pmarques
------------------------------------------------------------------------
pmarques's Profile: http://www.excelforum.com/member.php...o&userid=25110
View this thread: http://www.excelforum.com/showthread...hreadid=516130




pmarques[_9_]

macro to copy down formulas
 

*Hi Bernie Deitrick
Sorry for the delay
You are correct, It works for multiple columns.

It's a very useful macro, i recommend :)
Thanks a lot

:) :) :)*


--
pmarques
------------------------------------------------------------------------
pmarques's Profile: http://www.excelforum.com/member.php...o&userid=25110
View this thread: http://www.excelforum.com/showthread...hreadid=516130



All times are GMT +1. The time now is 08:06 AM.

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