+ Reply to Thread
Results 1 to 33 of 33

adding text to row a b and c while looping

  1. #1
    Registered User
    Join Date
    12-19-2012
    Location
    dublin ireand
    MS-Off Ver
    Excel 2007
    Posts
    98

    adding text to row a b and c while looping

    hi
    i have this code that copys and past stuff from another workbook and paste what i want from that work book to another work book in row d and e

    what i need is to add the same words to rows a b and c while its copying over my info from other sheet
    here is the code where it copies and paste the info over
    Please Login or Register  to view this content.
    is it possible to add text to the other rows while this is looping through and adding to sheet

    if so can anyone help

  2. #2
    Registered User
    Join Date
    12-19-2012
    Location
    dublin ireand
    MS-Off Ver
    Excel 2007
    Posts
    98

    Re: adding text to row a b and c while looping

    also code doesnt seem to work right

    what i want to happen is if i find the work gross nav in column ai and the word nok/ai in row c then copy the figure from row ai

    anyone any ideas why this cod wont work

  3. #3
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: adding text to row a b and c while looping

    I assume you want to write values to specific cells on the "NOK IA1" worksheet? The current process pastes the information in the target workbook on the current lastrow + 1 (determined separately for both column E and E). So if for eample you would like to write something to columns A and B you could insert the following code just before the Next i statement

    Please Login or Register  to view this content.
    or alternatively

    Please Login or Register  to view this content.
    If you like my contribution click the star icon!

  4. #4
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: adding text to row a b and c while looping

    I assume you want to write values to specific cells on the "NOK IA1" worksheet? The current process pastes the information in the target workbook on the current lastrow + 1 (determined separately for both column E and E). So if for eample you would like to write something to columns A and B you could insert the following code just before the Next i statement

    Please Login or Register  to view this content.
    or alternatively

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-19-2012
    Location
    dublin ireand
    MS-Off Ver
    Excel 2007
    Posts
    98

    Re: adding text to row a b and c while looping

    that great thank

    would u no any reason why the above code wouldnt pick the value i want if it find the text gross nav in one column and nok/ai in another column

  6. #6
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: adding text to row a b and c while looping

    Try replacing

    Please Login or Register  to view this content.
    by

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    12-19-2012
    Location
    dublin ireand
    MS-Off Ver
    Excel 2007
    Posts
    98

    Re: adding text to row a b and c while looping

    will try that thanks

  8. #8
    Registered User
    Join Date
    12-19-2012
    Location
    dublin ireand
    MS-Off Ver
    Excel 2007
    Posts
    98

    Re: adding text to row a b and c while looping

    still seems to be picing up all figures and not just the 1 figure

  9. #9
    Registered User
    Join Date
    12-19-2012
    Location
    dublin ireand
    MS-Off Ver
    Excel 2007
    Posts
    98

    Re: adding text to row a b and c while looping

    does this code make it look for just the whole word
    nok/a1

    as under that i have
    nok/a1a
    nok/a2
    nok/a2a

    so maybe thats causing the problem

  10. #10
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: adding text to row a b and c while looping

    I found your problem. replace the code with

    Please Login or Register  to view this content.
    You forgot the quotes around the column names AG and C, and I forgot the Format as percent. Because you have on error resume next, it skipped your IF statement and always conducted the update.
    Last edited by OllieB; 01-13-2013 at 03:54 PM.

  11. #11
    Registered User
    Join Date
    12-19-2012
    Location
    dublin ireand
    MS-Off Ver
    Excel 2007
    Posts
    98

    Re: adding text to row a b and c while looping

    what im trying to do

    is copy certain info from one book to another book.
    the figure i want is under the column ai
    but it can only be the figure from column c that has the words NOK/IA1

    here is a n example of the speard sheet
    Please Login or Register  to view this content.
    so i the figure from the gross nav column where NOK/IA1 from the class code or column c

  12. #12
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: adding text to row a b and c while looping

    I think this may the code you are looking for

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    12-19-2012
    Location
    dublin ireand
    MS-Off Ver
    Excel 2007
    Posts
    98

    Re: adding text to row a b and c while looping

    that doesnt seem to work

    and the example i gave just had 1 date in my sheet could have many so i need my looping around

    is there a way of keeping my code and just changing the bit where its picking up the line to copy over

  14. #14
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: adding text to row a b and c while looping

    Sorry, few typing errors

    try below code
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    12-19-2012
    Location
    dublin ireand
    MS-Off Ver
    Excel 2007
    Posts
    98

    Re: adding text to row a b and c while looping

    seems to lopp through it all right
    but its not printing it to the worksheet in workbook

  16. #16
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: adding text to row a b and c while looping

    Last attempt. Try the below code
    Please Login or Register  to view this content.
    If this does not work you will have to post copies of your workbooks.
    Last edited by OllieB; 01-13-2013 at 04:30 PM.

  17. #17
    Registered User
    Join Date
    12-19-2012
    Location
    dublin ireand
    MS-Off Ver
    Excel 2007
    Posts
    98

    Re: adding text to row a b and c while looping

    hi
    no still not writing to new workbook
    please find attached copy of the work books

    FND November 2012.xlsm
    Book4.xlsx

  18. #18
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: adding text to row a b and c while looping

    I will look at it tommorow. Is book4 open while you are running the code or are you assuming this code will open and save the workbook as well?

  19. #19
    Registered User
    Join Date
    12-19-2012
    Location
    dublin ireand
    MS-Off Ver
    Excel 2007
    Posts
    98

    Re: adding text to row a b and c while looping

    book 4 is open

    ill have to try solve this tonight myself as has to be done for tomorrow.

    thanks very much for all the help

  20. #20
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: adding text to row a b and c while looping

    I tried to have a look, but I am not able to download the file as I get a password protected message

  21. #21
    Registered User
    Join Date
    12-19-2012
    Location
    dublin ireand
    MS-Off Ver
    Excel 2007
    Posts
    98

    Re: adding text to row a b and c while looping

    HI
    try this book
    Book1.xlsx

  22. #22
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: adding text to row a b and c while looping

    I have looked at the workbooks provided and the description of your requirements, and they are quite confusing. For example column AG does not hold the description Gross NAV at all, column AI is supposed to be formatted as a percentage, but in fact contains an amount. The date you want to copy is not stored on the row itself, but at the beginning of a section. etc etc

    - Do you want to copy information from "book1" (worksheet Sheet1) to "FND November" (worksheet Allocation)?
    - which columns do you want to copy and where should the copied information be placed on the target worksheet?
    - When do you want to copy the information (i.e. the condition)

  23. #23
    Registered User
    Join Date
    12-19-2012
    Location
    dublin ireand
    MS-Off Ver
    Excel 2007
    Posts
    98

    Re: adding text to row a b and c while looping

    hi

    sorry that was me not fixing the code.
    -its going to go from "fnd november" to book 4 but as the fun november book is password protected i just copied and pasted it into book 1.
    so for this exmaple go from book 1 to book 4
    - i want to copy the value under the gross nav where in row c it has NOK/IA1
    - i want to copy it even time i run macro

  24. #24
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: adding text to row a b and c while looping

    I have looked at the workbooks provided and the description of your requirements, and they are quite confusing. For example column AG does not hold the description Gross NAV at all, column AI is supposed to be formatted as a percentage, but in fact contains an amount. The date you want to copy is not stored on the row itself, but at the beginning of a section. etc etc

    - Do you want to copy information from "book1" (worksheet Sheet1) to "FND November" (worksheet Allocation)?
    - which columns do you want to copy and where should the copied information be placed on the target worksheet?
    - When do you want to copy the information (i.e. the condition)

  25. #25
    Registered User
    Join Date
    12-19-2012
    Location
    dublin ireand
    MS-Off Ver
    Excel 2007
    Posts
    98

    Re: adding text to row a b and c while looping

    - Do you want to copy information from "book1" (worksheet Sheet1) to "FND November" (worksheet Allocation)?
    no lets copy it from "book1" (worksheet Sheet1) to book4 (worksheet NOK IA1)

    - which columns do you want to copy and where should the copied information be placed on the target worksheet?
    i want to copy the figure under gross nav column c = NOK IA1 and i want the date to be added to row d and the vaule it pick to be added to row d

    - When do you want to copy the information (i.e. the condition)
    every time i run macro i want to it copy and paste over

  26. #26
    Registered User
    Join Date
    12-19-2012
    Location
    dublin ireand
    MS-Off Ver
    Excel 2007
    Posts
    98

    Re: adding text to row a b and c while looping

    - Do you want to copy information from "book1" (worksheet Sheet1) to "FND November" (worksheet Allocation)?
    no lets copy it from "book1" (worksheet Sheet1) to book4 (worksheet NOK IA1)

    - which columns do you want to copy and where should the copied information be placed on the target worksheet?
    i want to copy the figure under gross nav column c = NOK IA1 and the date from first column.i want the date to be added to row d and the vaule it pick to be added to row d

    - When do you want to copy the information (i.e. the condition)
    every time i run macro i want to it copy and paste over

  27. #27
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: adding text to row a b and c while looping

    Ok. I have renamed the target workbook to Allocation, as that makes more sense to me. When you run the macro it will prompt you to select the FND November workbook. It will loop through all records identifying the sections (starting with a date) and for the records in that section will search for NOK/IA1 in column C. When found, it will add a record to the Allocation worksheet with the date in column A and the value of column AI in column B. Feel free to change this to meet you needs. Note that in the example provided column AI contain the value ZERO for every NOK/IA1 record.
    Attached Files Attached Files

  28. #28
    Registered User
    Join Date
    12-19-2012
    Location
    dublin ireand
    MS-Off Ver
    Excel 2007
    Posts
    98

    Re: adding text to row a b and c while looping

    thanks will have a look at that
    again thanks very much for all help

  29. #29
    Registered User
    Join Date
    12-19-2012
    Location
    dublin ireand
    MS-Off Ver
    Excel 2007
    Posts
    98

    Re: adding text to row a b and c while looping

    that worked
    again seriously thanks

  30. #30
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: adding text to row a b and c while looping

    Glad to hear.

    Will you please remember to mark this thread as SOLVED, and click on the star icon if you are happy with my contribution. Thank you.

  31. #31
    Registered User
    Join Date
    12-19-2012
    Location
    dublin ireand
    MS-Off Ver
    Excel 2007
    Posts
    98

    Re: adding text to row a b and c while looping

    hi
    do u think there is a way of improving this code
    Please Login or Register  to view this content.
    what its doing is looking for column ad or fund ownership copying and pasting the 4 line of figures under that column header

  32. #32
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: adding text to row a b and c while looping

    pls open a new thread for this request as it is not allowed (forum rules) to raise a new request in an existing thread. When you do raise a new thread, please ensure that your request is clearly formulated.

  33. #33
    Registered User
    Join Date
    12-19-2012
    Location
    dublin ireand
    MS-Off Ver
    Excel 2007
    Posts
    98

    Re: adding text to row a b and c while looping

    ok sorry forgot

+ Reply to 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