Closed Thread
Results 1 to 6 of 6

Want to Use the Same Macro in the second Row also

  1. #1
    Registered User
    Join Date
    06-11-2008
    Location
    Hyderabad
    Posts
    54

    Want to Use the Same Macro in the second Row also

    Hi All,

    I am a new user to this Exceltip.Com but profiecient in Excel. I Basically work on macro's.

    I got a problem in Macro just wanna to explain you the sequence:

    I got to have 4 Columns , in the first Column it is "1" , 2nd column it is "3", 3rd column it is "5" & the last column is Now().

    By writing a Macro i have brought the result for the 4 Columns the result will be displayed on the next column E as:

    A B C D E
    1 3 5 =now() 1-3-5-06/14/2008

    All the activity was done on first row with using all these Columns and a macro will be recorded on the first Row and first 5 Columns only.

    But i want to run the same macro in the second row also where as the macro recorded is for the first row and first 5 col's how can i use the same macro in the second row

    For Eg:

    A B C D E
    1 3 5 =now() 1-3-5-06/14/2008
    2 4 6 =now() 2-4-6-06/14/2008.

    Can any one help me as it would be helpfull for my daily spread sheet updations.

    Regards
    Surya.
    Last edited by VBA Noob; 06-17-2008 at 02:51 AM.

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523
    Hi Surya,

    See if the following code is what you're after:

    Please Login or Register  to view this content.
    HTH

    Robert

  3. #3
    Registered User
    Join Date
    06-11-2008
    Location
    Hyderabad
    Posts
    54

    Hi Trebor

    Thanks for the code but it is not relevant to my requirement please see the below so that it can be more useful.

    A B C D E
    1 Kolkata Q1 2-Jun-08 RFQ-KOL-001-06-08-Q1
    2 Delhi Q1 2-Jun-08 ?


    The Above is an example, i have generated a Macro for First Row:

    The Macro will be as below:

    ActiveCell.FormulaR1C1 = "1"
    Range("B2").Select
    ActiveCell.FormulaR1C1 = "KOL"
    Range("C2").Select
    ActiveCell.FormulaR1C1 = "Q1"
    Range("D2").Select
    ActiveCell.FormulaR1C1 = "=NOW()"
    Range("E2").Select
    ActiveCell.FormulaR1C1 = "=""RFQ"""
    Range("E2").Select
    ActiveCell.FormulaR1C1 = _
    "=""RFQ""&""-""&RC[-3]&""-""&""-""&RC[-4]&""-""&MONTH(RC[-1])"
    Range("E2").Select
    ActiveCell.FormulaR1C1 = _
    "=""RFQ""&""-""&RC[-3]&""-""&""-""&RC[-4]&""-""&MONTH(RC[-1])&""-""&YEAR(RC[-1])&""-""&RC[-2]"
    Range("E2").Select
    End Sub

    The Same formula should be able to run on the place where i place on the cell on the excel sheet can be this done.Becuase i have recorded on the first row but it should be applicable to all the rows of first 4 Columns thats my concern is......

    Thanks

    Surya.

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi suryaprasad,

    Please wrap you code like Trebor76 has done as per forum rules below


    Thanks

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  5. #5
    Registered User
    Join Date
    06-11-2008
    Location
    Hyderabad
    Posts
    54

    Hi Trebor

    Thanks for the code but it is not relevant to my requirement please see the below so that it can be more useful.

    A B C D E
    1 Kolkata Q1 2-Jun-08 RFQ-KOL-001-06-08-Q1
    2 Delhi Q1 2-Jun-08 ?


    The Above is an example, i have generated a Macro for First Row:

    The Macro will be as below:

    ActiveCell.FormulaR1C1 = "1"
    Range("B2").Select
    ActiveCell.FormulaR1C1 = "KOL"
    Range("C2").Select
    ActiveCell.FormulaR1C1 = "Q1"
    Range("D2").Select
    ActiveCell.FormulaR1C1 = "=NOW()"
    Range("E2").Select
    ActiveCell.FormulaR1C1 = "=""RFQ"""
    Range("E2").Select
    ActiveCell.FormulaR1C1 = _
    "=""RFQ""&""-""&RC[-3]&""-""&""-""&RC[-4]&""-""&MONTH(RC[-1])"
    Range("E2").Select
    ActiveCell.FormulaR1C1 = _
    "=""RFQ""&""-""&RC[-3]&""-""&""-""&RC[-4]&""-""&MONTH(RC[-1])&""-""&YEAR(RC[-1])&""-""&RC[-2]"
    Range("E2").Select
    End Sub

    The Same formula should be able to run on the place where i place on the cell on the excel sheet can be this done.Becuase i have recorded on the first row but it should be applicable to all the rows of first 4 Columns thats my concern is......

    Thanks

    Surya.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    suryaprasad

    You don't seem to think that it is necessary to read and/or follow the Forum Rules. You have broken them twice now in only six posts. I strongly suggest that you read them 7 if you don't understand ask for help, if you don't you will find you are not allowed to post questions.

    You also seem to be ignoring Moderators, so post locked until you let us know that you have read & will follow the Rules.

    Next stp will be a ban!!
    Last edited by royUK; 06-17-2008 at 04:24 AM.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1