+ Reply to Thread
Results 1 to 9 of 9

Macro for unexpected scenario

  1. #1
    Registered User
    Join Date
    03-06-2014
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    47

    Macro for unexpected scenario

    Hi,

    I have data like below in excel sheet.Sheet1 contains similar type of records nearly 3000records in below format.I need to add data from row2 to row13 to Number.I need macro for adding below records from row2 ro row13 to column number

    Any one provide macro for this

    sheet1:

    empid name loc age player Number
    1 a b c d 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12

    Output:

    empid name loc age player Number
    1 a b c d 123456789101112

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Macro for unexpected scenario

    Still not clear what you are trying to do


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Karlstad, Sweden
    MS-Off Ver
    Excel 2016
    Posts
    232

    Re: Macro for unexpected scenario

    Try this.

    I have written the new number i a messagebox. Remove comment (') if you want to write the new number in cell F2

    Please Login or Register  to view this content.
    1. Reply to thread and inform if suggestion was helpful or not
    2. Click on the star (=Add Reputation) if you think someone helped you
    3. Mark [SOLVED] to this thread if solution was found. (On Menu "Thread Tools" > "Mark this thread as solved")

  4. #4
    Registered User
    Join Date
    03-06-2014
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Macro for unexpected scenario

    Hi jOakin,

    I have Remove the comment for Range("F2").Value = sNumber.its working fine.But the problem is It is working only for one row only.
    After A12 i have rows like that only.But it is not working for remaining records.

  5. #5
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Karlstad, Sweden
    MS-Off Ver
    Excel 2016
    Posts
    232

    Re: Macro for unexpected scenario

    Can youn provide the workbook? It easier to see the structure.

  6. #6
    Registered User
    Join Date
    03-06-2014
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Macro for unexpected scenario

    Hi Joakin,

    Plase check the attached dat for reference.sheet1 contains input data.sheet2 contains output data.sheet1 has many number of records i have added only 3 records for reference.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Karlstad, Sweden
    MS-Off Ver
    Excel 2016
    Posts
    232

    Re: Macro for unexpected scenario

    Try this:

    Testdata.xlsm

  8. #8
    Registered User
    Join Date
    03-06-2014
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Macro for unexpected scenario

    Hi Joakin,

    Thx for the code.But the problem is some of the rows coming with different length.You hardcoded in your code for 11.But some of the rows contain only 3 records.So in that case it is failing.
    So macro should concatenated that records to last column whenever row has only one column data.

  9. #9
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Karlstad, Sweden
    MS-Off Ver
    Excel 2016
    Posts
    232

    Re: Macro for unexpected scenario

    Now you can have different number of rows (Previous all = 11)

    Testdata.xlsm

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro with Solver. An unexpected internal error occurred, or available memory
    By sofiaventura in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-26-2013, 04:24 PM
  2. Scenario Manager displays same result for every scenario
    By terihoff in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 11-10-2012, 07:14 PM
  3. Unexpected crash after macro execution
    By szabi7 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-05-2012, 06:05 AM
  4. Replies: 0
    Last Post: 08-16-2012, 01:32 PM
  5. Unexpected run time error in Macro
    By Athilla in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-22-2009, 12:31 AM

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