+ Reply to Thread
Results 1 to 3 of 3

Problem with a loop

  1. #1
    Registered User
    Join Date
    08-19-2015
    Location
    x
    MS-Off Ver
    2010
    Posts
    10

    Problem with a loop

    Hello,

    I'm writing a script that selects certain values on a pivot chart slicer, and based on that sends an email containing the corresponding pivot data and chart. I have to do it for multiple values, which may change depending on version of the file currently in use.
    Now I got the functional part of the code working, meaning it selects the correct item on the slicer and creates the email message I want, so I can theoretically do it in blocks, but then I would have to define all the values for the slicer selection in the code, making it highly impractical. I need the code to draw the values for the slicer selection from a range of cells on another worksheet, and this is the part I can't get to work.

    The functional segment of the code, looks like this:


    Please Login or Register  to view this content.
    Now let's say the values I need to loop through are in Sheets("InfoData").Range("A22:A32")

    What I tried to do was:

    newSelection = ActiveCell.Value

    and the put the whole block in a loop

    Please Login or Register  to view this content.
    but It would always return an error at this point

    Sheets("Infodata").Cells(x, 1).Select

    Strangely enough not the same error every time.

    I'm completely lost.

  2. #2
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Problem with a loop

    What is this actually for?

    Please Login or Register  to view this content.
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  3. #3
    Registered User
    Join Date
    08-19-2015
    Location
    x
    MS-Off Ver
    2010
    Posts
    10

    Re: Problem with a loop

    Nevermind I actually made it work, but for some reason the list had to be on the some worksheet, othwerwise excel refuses to cooperate.

    And for your question:

    newselection contains the value that I need to select on the slicer, and since I need to do it for 10+ usernames I thought I would make excel select one username after another, and base the the variable on the currently selected cell.

+ 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] Loop problem
    By Jess0121 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-12-2015, 02:36 PM
  2. Problem with 2 loop in VBA
    By hitmen in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-09-2015, 12:17 AM
  3. [SOLVED] Another loop problem
    By SIMBAtheCAT in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-18-2014, 12:21 PM
  4. 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
  5. [SOLVED] Loop inside a loop problem!
    By questionguy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-22-2012, 12:54 PM
  6. Loop problem
    By reggie1000 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-04-2011, 06:16 PM
  7. 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