Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Macro Script

Folks,
I have the following Macro Script generated by recording Excel steps:

Range("D2").Select
ActiveCell.FormulaR1C1 = "=RC[-1]&"" ""&RC[4]"
Range("D2").Select
Selection.AutoFill Destination:=Range("D2:D14")
Range("D2:D14").Select

This is basically concatenating the content of 2 other cells in D2 and then
copying down the formula....
as you can see when I am recording the copy down step by doubleclicking into
the corner of cell D2 it is copying until D14 which happens to be the end of
the current data range....

Now, with this structure it will always stop at D14 regardless of the number
of rows...is there anyway I can add a syntax so that the macro will
automatically evaluate to the last row of Column D to autoFill the formula?

Thanks in advance for your help.

Regards,
Shams.




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Macro Script

I think you want the last row of Column C since there is no data in column D
until you put in the formula

LastRow = Range("C" & Rows.Count).end(xlup).Row
Range("D2").FormulaR1C1 = "=RC[-1]&"" ""&RC[4]"
Range("D2").AutoFill Destination:=Range("D2:D" & LastRow)


"Shams" wrote:

Folks,
I have the following Macro Script generated by recording Excel steps:

Range("D2").Select
ActiveCell.FormulaR1C1 = "=RC[-1]&"" ""&RC[4]"
Range("D2").Select
Selection.AutoFill Destination:=Range("D2:D14")
Range("D2:D14").Select

This is basically concatenating the content of 2 other cells in D2 and then
copying down the formula....
as you can see when I am recording the copy down step by doubleclicking into
the corner of cell D2 it is copying until D14 which happens to be the end of
the current data range....

Now, with this structure it will always stop at D14 regardless of the number
of rows...is there anyway I can add a syntax so that the macro will
automatically evaluate to the last row of Column D to autoFill the formula?

Thanks in advance for your help.

Regards,
Shams.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Macro Script

Joel,
Thank you for your fast input. Yes! This seems to be working flawlessly!!
I basically replaced my syntax with what you provided me and it makes good
sense.

"Joel" wrote:

I think you want the last row of Column C since there is no data in column D
until you put in the formula

LastRow = Range("C" & Rows.Count).end(xlup).Row
Range("D2").FormulaR1C1 = "=RC[-1]&"" ""&RC[4]"
Range("D2").AutoFill Destination:=Range("D2:D" & LastRow)


"Shams" wrote:

Folks,
I have the following Macro Script generated by recording Excel steps:

Range("D2").Select
ActiveCell.FormulaR1C1 = "=RC[-1]&"" ""&RC[4]"
Range("D2").Select
Selection.AutoFill Destination:=Range("D2:D14")
Range("D2:D14").Select

This is basically concatenating the content of 2 other cells in D2 and then
copying down the formula....
as you can see when I am recording the copy down step by doubleclicking into
the corner of cell D2 it is copying until D14 which happens to be the end of
the current data range....

Now, with this structure it will always stop at D14 regardless of the number
of rows...is there anyway I can add a syntax so that the macro will
automatically evaluate to the last row of Column D to autoFill the formula?

Thanks in advance for your help.

Regards,
Shams.




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
Macro Script help Joe Clueless Excel Worksheet Functions 4 January 24th 10 05:32 PM
VB script/macro help - please !! Anthony Excel Discussion (Misc queries) 2 July 10th 05 07:58 PM
Macro or script JIM80215 Excel Programming 1 November 16th 03 10:02 PM
Macro or Script??? milton Excel Programming 2 October 22nd 03 09:46 PM


All times are GMT +1. The time now is 06:19 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"