+ Reply to Thread
Results 1 to 12 of 12

Another loop problem

  1. #1
    Registered User
    Join Date
    06-03-2014
    MS-Off Ver
    2007
    Posts
    87

    Another loop problem

    Hi,

    I am making a loop to insert values in every Range("A1") of every sheet corresponding. However, when I run the code, it doesn't insert any value.

    Please Login or Register  to view this content.
    Last edited by SIMBAtheCAT; 06-18-2014 at 12:21 PM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Another loop problem

    You aren't looping through sheets, you are looping through the range A1:A10000 on the sheet 'Présentation'.

    Does that range have sheet names?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    06-03-2014
    MS-Off Ver
    2007
    Posts
    87

    Re: Another loop problem

    Yes, the ranges correspond to sheet names.

    There is many more range in this sheet that I want to select the value that is why I'm looping through the sheet.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Another loop problem

    To loop through the sheets in a workbook you would normally use something like this.
    Please Login or Register  to view this content.
    If you have the names of the sheets you want to loop through in column A of a particular sheet then you would do it like this.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-03-2014
    MS-Off Ver
    2007
    Posts
    87

    Re: Another loop problem

    Great, now it copies the value but the wrong ones. Could you help to copy the value just one cell up of the sheet name in the main sheet. Here is how the "Présentation" sheet looks like :


    - 3 -
    CRTC - SOMMAIRE FINANCIER - SERVICES SPÉCIALISÉS ET PAYANTS

    # D'ENTREPRISE Nom du service Titulaire Propriétaire ultime Type Année
    tv channel blabla Communications Co- Vidéo sur demande 2013'That is the value I'm looking the copy for every sheet corresponding in Range("A1")
    Regina operative Limited operative Limited
    Feuille12'That is the sheet name
    TCAC = Taux de croissance annuel composé


    - 4 -
    CRTC - FINANCIAL SUMMARY - PAID SERVICES

    # D'ENTREPRISE Nom du service Titulaire Propriétaire ultime Type Année
    tvchannel1 inc. Service spécialisé (cat. A) 2013 'That is the value I'm looking the copy for every sheet corresponding in Range("A1")
    Feuille13 'That is the sheet name
    TCAC = Taux de croissance annuel composé

    etcetera ... to "Feuille263" or in English "Sheet263"
    Please Login or Register  to view this content.
    Last edited by SIMBAtheCAT; 06-18-2014 at 10:44 AM.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Another loop problem

    To get the cell one row above use Offset(,-1).
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    06-03-2014
    MS-Off Ver
    2007
    Posts
    87

    Re: Another loop problem

    Perfect, one last issue. It seems to jump a sheet so the last one "Feuille263" is empty and all the titles are on the wrong sheet.

  8. #8
    Registered User
    Join Date
    06-03-2014
    MS-Off Ver
    2007
    Posts
    87

    Re: Another loop problem

    Worst, now the code run but simply does nothing. Here is the file to sort this issue faster (File barely exceed the limit size of the forum) :
    Last edited by SIMBAtheCAT; 06-18-2014 at 12:23 PM.

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Another loop problem

    Can you upload an example workbook here?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

  10. #10
    Registered User
    Join Date
    06-03-2014
    MS-Off Ver
    2007
    Posts
    87

    Re: Another loop problem

    Sure, but keep in mind that I had to delete a couple of sheets to make it lighter.
    Last edited by SIMBAtheCAT; 06-18-2014 at 12:24 PM.

  11. #11
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Another loop problem

    Oops, mixed up rows/columns in the offset.
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    06-03-2014
    MS-Off Ver
    2007
    Posts
    87

    Re: Another loop problem

    Perfect! Thanks for your help Norie.

+ 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. Vlookup problem in a loop with cell property and variable cell problem (long title sry)
    By ExcelsiorLux in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-13-2013, 10:38 AM
  2. [SOLVED] Loop inside a loop problem!
    By questionguy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-22-2012, 12:54 PM
  3. 'Loop Until' Problem
    By Iwasiw35 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-08-2011, 07:57 PM
  4. VBA LOOP Problem
    By sullnok in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-14-2009, 12:54 PM
  5. Problem adding charts using Do-Loop Until loop
    By Chris Bromley in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-23-2005, 09:06 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