Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Better way to apply formula to multiple cells?


Hi all,

First post, long time reader...

I've pasted some code below that does the following steps:
1.) Specifies a formula to combine two cells values into one
2.) Copy that formula and apply it to remaining records
3.) Convert the formula to a value (so that I can delete the source
rows)

This code works - but is there a sexier way to code this?

Thanks everyone!

- Brian



'Combine two column values for first record
Range("E4").Select
ActiveCell.FormulaR1C1 = "=TRIM(RC[-2]) & "" "" & RC[-1]"

'Copy formula and paste to additional records
Range("E4").Select
Selection.Copy
Range("E5:E17").Select
ActiveSheet.Paste

'Copy and paste special formulas as values
Range("E4:E17").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False


--
bntringa
------------------------------------------------------------------------
bntringa's Profile: http://www.excelforum.com/member.php...o&userid=30523
View this thread: http://www.excelforum.com/showthread...hreadid=501753

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Better way to apply formula to multiple cells?

Depneds what you maen by sexy <G

With Range("E5:E17")
.FormulaR1C1 = "=TRIM(RC[-2])&"" ""&RC[-1]"
.Value = .Value
End With


HTH

Bob

"bntringa" wrote in
message ...

Hi all,

First post, long time reader...

I've pasted some code below that does the following steps:
1.) Specifies a formula to combine two cells values into one
2.) Copy that formula and apply it to remaining records
3.) Convert the formula to a value (so that I can delete the source
rows)

This code works - but is there a sexier way to code this?

Thanks everyone!

- Brian



'Combine two column values for first record
Range("E4").Select
ActiveCell.FormulaR1C1 = "=TRIM(RC[-2]) & "" "" & RC[-1]"

'Copy formula and paste to additional records
Range("E4").Select
Selection.Copy
Range("E5:E17").Select
ActiveSheet.Paste

'Copy and paste special formulas as values
Range("E4:E17").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False


--
bntringa
------------------------------------------------------------------------
bntringa's Profile:

http://www.excelforum.com/member.php...o&userid=30523
View this thread: http://www.excelforum.com/showthread...hreadid=501753



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Better way to apply formula to multiple cells?


Hey that IS sexy!

Thanks for the help Bob!


--
bntringa
------------------------------------------------------------------------
bntringa's Profile: http://www.excelforum.com/member.php...o&userid=30523
View this thread: http://www.excelforum.com/showthread...hreadid=501753

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Better way to apply formula to multiple cells?

pity my spelling isn't <vbg

--
HTH

RP
"bntringa" wrote in
message ...

Hey that IS sexy!

Thanks for the help Bob!


--
bntringa
------------------------------------------------------------------------
bntringa's Profile:

http://www.excelforum.com/member.php...o&userid=30523
View this thread: http://www.excelforum.com/showthread...hreadid=501753



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Better way to apply formula to multiple cells?


Hey that IS sexy!

Thanks for the help Bob!


--
bntringa
------------------------------------------------------------------------
bntringa's Profile: http://www.excelforum.com/member.php...o&userid=30523
View this thread: http://www.excelforum.com/showthread...hreadid=501753



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
how to apply absolute cell referencing to multiple cells at once? TheresaP Excel Worksheet Functions 3 April 3rd 23 02:24 PM
How can I apply a function (PROPER) to multiple cells at once? AGrozier Excel Worksheet Functions 3 December 3rd 07 07:54 AM
apply arithmetic functions on special multiple cells Zhekka Excel Worksheet Functions 5 February 10th 06 02:04 AM
apply a formula to multiple cells FixitFrog Excel Discussion (Misc queries) 3 June 23rd 05 11:54 AM
How do I apply a combo box to multiple cells in Excel so that it . DB Excel Discussion (Misc queries) 1 January 12th 05 03:42 PM


All times are GMT +1. The time now is 11:34 PM.

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

About Us

"It's about Microsoft Excel"