Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Biff
 
Posts: n/a
Default Optimize simple macro

Hi folks!

I have this simple macro that was created using the recorder.

Sub foo()

Rows("2:2").Select
Selection.Insert Shift:=xlDown
Range("G2").Select
ActiveCell.FormulaR1C1 = "=RC[-5]&RC[-4]&RC[-3]&RC[-2]&RC[-1]"
Range("A1").Select

End Sub

It simply inserts a new row 2 and places a concatenation formula in cell G2.

How can this be optimized? I know SELECTS are undesireable but I'm more
interested in how to get the formula in A1 reference style.

Thanks!

Biff


  #4   Report Post  
Peo Sjoblom
 
Posts: n/a
Default

Try

ActiveCell.Formula = "=B2&C2&D2&E2&F2"


Regards,

Peo Sjoblom

"Biff" wrote:

Hi folks!

I have this simple macro that was created using the recorder.

Sub foo()

Rows("2:2").Select
Selection.Insert Shift:=xlDown
Range("G2").Select
ActiveCell.FormulaR1C1 = "=RC[-5]&RC[-4]&RC[-3]&RC[-2]&RC[-1]"
Range("A1").Select

End Sub

It simply inserts a new row 2 and places a concatenation formula in cell G2.

How can this be optimized? I know SELECTS are undesireable but I'm more
interested in how to get the formula in A1 reference style.

Thanks!

Biff



  #6   Report Post  
Dana DeLouis
 
Posts: n/a
Default

interested in how to get the formula in A1 reference style.

Would this idea work? HTH :)

Sub foo()
Rows(2).Insert
Range("G2").Formula = "=B2&C2&D2&E2&F2"
Range("A1").Select
End Sub

--
Dana DeLouis
Win XP & Office 2003


"Biff" wrote in message
...
Hi folks!

I have this simple macro that was created using the recorder.

Sub foo()

Rows("2:2").Select
Selection.Insert Shift:=xlDown
Range("G2").Select
ActiveCell.FormulaR1C1 = "=RC[-5]&RC[-4]&RC[-3]&RC[-2]&RC[-1]"
Range("A1").Select

End Sub

It simply inserts a new row 2 and places a concatenation formula in cell
G2.

How can this be optimized? I know SELECTS are undesireable but I'm more
interested in how to get the formula in A1 reference style.

Thanks!

Biff




  #7   Report Post  
Biff
 
Posts: n/a
Default

Thanks, Peo.

Biff

"Peo Sjoblom" wrote in message
...
Try

ActiveCell.Formula = "=B2&C2&D2&E2&F2"


Regards,

Peo Sjoblom

"Biff" wrote:

Hi folks!

I have this simple macro that was created using the recorder.

Sub foo()

Rows("2:2").Select
Selection.Insert Shift:=xlDown
Range("G2").Select
ActiveCell.FormulaR1C1 = "=RC[-5]&RC[-4]&RC[-3]&RC[-2]&RC[-1]"
Range("A1").Select

End Sub

It simply inserts a new row 2 and places a concatenation formula in cell
G2.

How can this be optimized? I know SELECTS are undesireable but I'm more
interested in how to get the formula in A1 reference style.

Thanks!

Biff





  #8   Report Post  
Biff
 
Posts: n/a
Default

Thanks, Dana.

One of these days I'll get into VBA!

Biff

"Dana DeLouis" wrote in message
...
interested in how to get the formula in A1 reference style.


Would this idea work? HTH :)

Sub foo()
Rows(2).Insert
Range("G2").Formula = "=B2&C2&D2&E2&F2"
Range("A1").Select
End Sub

--
Dana DeLouis
Win XP & Office 2003


"Biff" wrote in message
...
Hi folks!

I have this simple macro that was created using the recorder.

Sub foo()

Rows("2:2").Select
Selection.Insert Shift:=xlDown
Range("G2").Select
ActiveCell.FormulaR1C1 = "=RC[-5]&RC[-4]&RC[-3]&RC[-2]&RC[-1]"
Range("A1").Select

End Sub

It simply inserts a new row 2 and places a concatenation formula in cell
G2.

How can this be optimized? I know SELECTS are undesireable but I'm more
interested in how to get the formula in A1 reference style.

Thanks!

Biff






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
Need Help With A Very Simple Macro Amca Excel Discussion (Misc queries) 3 May 7th 05 12:10 AM
Simple Hyperlink Macro Rebecca New Users to Excel 3 April 10th 05 08:21 AM
Date macro Hiking Excel Discussion (Misc queries) 9 February 3rd 05 12:40 AM
New Excel user needs help with simple Macro... Rahim Kassam New Users to Excel 1 January 24th 05 02:10 PM
Can't get simple macro to run Abi Excel Worksheet Functions 5 January 12th 05 07:37 PM


All times are GMT +1. The time now is 01:41 PM.

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"