Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Pasting custom formula

I am trying to paste a custom built formula in a variable location with a VBA
routine. I have to find the first open row at the end of a list, find the row
number and build a formula using a reference from that row number and paste
it into a cell on that row.

Specifically I need to build a formula that looks something like this:
assuming the first row found is 10 and I want to test a value in cell A10
(that I just pasted there with the same routine) I have a referenced variable
in $C$1, and I want to paste this new formula in C10. The formula looks
something like this =if(C$1$A10,"Yes","No").

My list keeps getting longer so I need a dynamic way to build a new formula
for each row (hopefully a simple formula that runs fast). Can anyone help
with a bit of code for this?

Thanks in advance,
RDW
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Pasting custom formula

Sub PutInFormula()
Dim lastrow as Long
lastrow = cells(rows.count,"C").End(xlup).row + 1
cells(lastrow,"C").formula = _
"=if(C$1$A" & lastrow & ",""Yes"",""No"")"
End sub

--
Regards,
Tom Ogilvy


"RD Wirr" wrote:

I am trying to paste a custom built formula in a variable location with a VBA
routine. I have to find the first open row at the end of a list, find the row
number and build a formula using a reference from that row number and paste
it into a cell on that row.

Specifically I need to build a formula that looks something like this:
assuming the first row found is 10 and I want to test a value in cell A10
(that I just pasted there with the same routine) I have a referenced variable
in $C$1, and I want to paste this new formula in C10. The formula looks
something like this =if(C$1$A10,"Yes","No").

My list keeps getting longer so I need a dynamic way to build a new formula
for each row (hopefully a simple formula that runs fast). Can anyone help
with a bit of code for this?

Thanks in advance,
RDW

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Pasting custom formula

That works perfectly. Thanks Tom!

"Tom Ogilvy" wrote:

Sub PutInFormula()
Dim lastrow as Long
lastrow = cells(rows.count,"C").End(xlup).row + 1
cells(lastrow,"C").formula = _
"=if(C$1$A" & lastrow & ",""Yes"",""No"")"
End sub

--
Regards,
Tom Ogilvy


"RD Wirr" wrote:

I am trying to paste a custom built formula in a variable location with a VBA
routine. I have to find the first open row at the end of a list, find the row
number and build a formula using a reference from that row number and paste
it into a cell on that row.

Specifically I need to build a formula that looks something like this:
assuming the first row found is 10 and I want to test a value in cell A10
(that I just pasted there with the same routine) I have a referenced variable
in $C$1, and I want to paste this new formula in C10. The formula looks
something like this =if(C$1$A10,"Yes","No").

My list keeps getting longer so I need a dynamic way to build a new formula
for each row (hopefully a simple formula that runs fast). Can anyone help
with a bit of code for this?

Thanks in advance,
RDW

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
retain custom date format "text" when pasting or reformatting data frustrated worker Excel Discussion (Misc queries) 2 October 28th 09 06:03 PM
custom field with custom formula in pivot table! Sedaghat Nejad Excel Worksheet Functions 2 June 21st 09 11:19 AM
Custom error bars bug -- copy pasting chart does not update refere badpazzword Charts and Charting in Excel 5 April 12th 09 02:11 PM
Pasting on Filtered Data Sheets without pasting onto hidden cells CCSMCA Excel Discussion (Misc queries) 1 August 28th 05 01:22 PM
Pasting formula as text ExcelMonkey[_190_] Excel Programming 3 March 14th 05 11:48 PM


All times are GMT +1. The time now is 12:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"