ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   To execute a formula upto in a cell (https://www.excelbanter.com/excel-discussion-misc-queries/199684-execute-formula-upto-cell.html)

pol

To execute a formula upto in a cell
 
Please give me help

How I can write a macro in excel for copy and paste a formula with
depending upon the value of next right cell

For example I have a formula in cell A1 to get numeric value from alpha
numeric value in cell B1 . That forumula I have to copy down from A upto
the data contained in next cell B . ie, that may to copy from A1..A10 or from
A1..30 that is depending the data of B cell

Please Help
With Thanks and Regdards
Pol




joel

To execute a formula upto in a cell
 
The best way is to use a worksheet change macro. When the data in colum nB
is entered automatically put the formula to the cell immediately to the left.

Private Sub Worksheet_Change(ByVal Target as Range)
if Target.Column = 2 then
Target.offset(0,-1).formula = "=B" & Target.Row & "+1"
end if
End Sub

Which will put in Column A5 "= B5 + 1" when cell B5 is changed


"pol" wrote:

Please give me help

How I can write a macro in excel for copy and paste a formula with
depending upon the value of next right cell

For example I have a formula in cell A1 to get numeric value from alpha
numeric value in cell B1 . That forumula I have to copy down from A upto
the data contained in next cell B . ie, that may to copy from A1..A10 or from
A1..30 that is depending the data of B cell

Please Help
With Thanks and Regdards
Pol




Dave Peterson

To execute a formula upto in a cell
 
Option Explicit
Sub Testme()
Dim Wks as worksheet
dim LastRow as long

set wks = activesheet

with activesheet
lastrow = .cells(.rows.count,"B").end(xlup).row
.range("a1:A" & lastrow).formular1c1 = .range("A1").formular1c1
end with
End sub


pol wrote:

Please give me help

How I can write a macro in excel for copy and paste a formula with
depending upon the value of next right cell

For example I have a formula in cell A1 to get numeric value from alpha
numeric value in cell B1 . That forumula I have to copy down from A upto
the data contained in next cell B . ie, that may to copy from A1..A10 or from
A1..30 that is depending the data of B cell

Please Help
With Thanks and Regdards
Pol


--

Dave Peterson

pol

To execute a formula upto in a cell
 
Thnks a lot . thnks again

"Dave Peterson" wrote:

Option Explicit
Sub Testme()
Dim Wks as worksheet
dim LastRow as long

set wks = activesheet

with activesheet
lastrow = .cells(.rows.count,"B").end(xlup).row
.range("a1:A" & lastrow).formular1c1 = .range("A1").formular1c1
end with
End sub


pol wrote:

Please give me help

How I can write a macro in excel for copy and paste a formula with
depending upon the value of next right cell

For example I have a formula in cell A1 to get numeric value from alpha
numeric value in cell B1 . That forumula I have to copy down from A upto
the data contained in next cell B . ie, that may to copy from A1..A10 or from
A1..30 that is depending the data of B cell

Please Help
With Thanks and Regdards
Pol


--

Dave Peterson



All times are GMT +1. The time now is 10:08 PM.

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