+ Reply to Thread
Results 1 to 11 of 11

Select Certain Cells within Range

Hybrid View

  1. #1
    Registered User
    Join Date
    08-27-2007
    Location
    Australia
    Posts
    60

    Select Certain Cells within Range

    Hi All,

    Prior to getting to this stage;
    • a number of cells have already been selected.
    • Sheets(MySheetName).Range("A3") adds up those cells that = "#N/A Requesting Data..."

    "c" in the code below is referring to these pre-selected cells.

    What I was hoping to do was;
    • if the cell value is not "#N/A Requesting Data..." de-select the cell
    • for remaining cells that are selected, calculate those cells
    • continue to loop until Sheets(MySheetName).Range("A3") is 0.

    Currently the code calculates all cells;

    Sub Verify_Update()
    
    MySheetName = Sheets("Main").Range("C37").Value & "_Data"
    
    Sheets(MySheetName).Range("A3").Calculate
    
    If Sheets(MySheetName).Range("A3").Value <> 0 Then
    
    Dim c As Range
        
      For Each c In Selection.Cells
       If c.Value = "#N/A Requesting Data..." Then
                Sheets(MySheetName).Calculate
                Call Application.OnTime(Now + TimeValue("00:00:05"), "Verify_Update")
                Exit Sub
            End If
        Next c
    
    Else: Sheets("List").Range("H1").Value = Sheets("List").Range("H1").Value + 1
    Call Copy_Data
    
    End If
    
    End Sub

    Any help would be great!

    Thanks

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Select Certain Cells within Range

    Hi,

    Are there some cells that are NOT selected but have the value "#N/A Requesting Data..."

    Incidentally would you add your location to your profile. It often helps when responding to questions.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    08-27-2007
    Location
    Australia
    Posts
    60

    Re: Select Certain Cells within Range

    Hi Richard,

    Just confirming that all cells that have the value "#N/A Requesting Data..." are to be selected.
    And the VBA code just keeps looping until a value is finally downloaded and there are no "#N/A Requesting Data..." cells left.

    Thanks

    Tejay

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Select Certain Cells within Range

    Hi,

    In that case can't you use a simple SUMIF or SUMIFS to sum the relevant column where the criteria column has the #N/A...text?

  5. #5
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Select Certain Cells within Range

    Try this

    Dim celrng As Range
    
    Set celrng =Sheets(MySheetName).cells.SpecialCells(xlCellTypeConstants)
    
      For Each c In celrng
    
    "your code"
    Last edited by kvsrinivasamurthy; 11-06-2015 at 07:41 AM.

  6. #6
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Select Certain Cells within Range

    Duplicate deleted.
    Last edited by kvsrinivasamurthy; 11-06-2015 at 07:38 AM.

  7. #7
    Registered User
    Join Date
    08-27-2007
    Location
    Australia
    Posts
    60

    Re: Select Certain Cells within Range

    Hi All,

    Thanks Kvsrinivasamurthy, I presume your code will just select any cell on "MySheetName" that has the value "#N/A Requesting Data..."?

    Richard at the moment I think I am effectively doing that, I have a cell Sheets(MySheetName).Range("A3") that has:
    • IFERROR(IF(B6="#N/A Requesting Data...",1,0),0)+IFERROR(IF(D6="#N/A Requesting Data...",1,0),0)....

    If Kvsrinivasamurthy code will just select any cell with "#N/A Requesting Data..." thats even better and will help with some other things.

    In my original code I have;
       If c.Value = "#N/A Requesting Data..." Then
                Sheets(MySheetName).Calculate
    Is it possible to just re-calculate the selected cells each time instead of the whole sheet?


    Thanks

  8. #8
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Select Certain Cells within Range

    Hi,

    I'm struggling to understand why you need to select any cells if all you want is to sum all cells in a column that has "#N/A Requesting Data" in another column on the same row which can be done with a SUMIFS()

    If we could see your workbook in which you have manually entered some typical results, telling us which are the result cells this would be easier to confirm.

  9. #9
    Registered User
    Join Date
    08-27-2007
    Location
    Australia
    Posts
    60

    Re: Select Certain Cells within Range

    Hi Richard,

    All of the "#N/A Requesting Data" are not on the same row or column.
    Here are two screen shots from the sheet;

    delete1.JPG

    delete2.JPG

    So I know where the "#N/A Requesting Data" will appear.

    The code I had was to keep looping until the sum of all those cells summed to 0.
    They can sum to 0 by either spitting out data or an error, in both cases the "#N/A Requesting Data" disappears.

    So what would be great is if;
    • Only the cells which contain "#N/A Requesting Data" are selected
    • Only the selected cells are re-calculated

    Hope that makes more sense?

    Thanks

  10. #10
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Select Certain Cells within Range

    Hi,

    Upload the workbook as suggested with some manually entered results - make sure you cover all combinations/permutations and maybe we can make some progress.

  11. #11
    Registered User
    Join Date
    08-27-2007
    Location
    Australia
    Posts
    60

    Re: Select Certain Cells within Range

    Hi Again,

    For this to work, it needs to be connected to a data terminal which I only have at work.

    Eitherway, attached is a simplified version of this spreadsheet.

    Cell A3 sums all the cells that data is to appear in.
    And the VBA code is to keep looping to force data to download until either it does or the data terminal displays an error value.

    Thanks for your help

    Tejay
    Attached Files Attached Files

+ 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. Cant select a range of cells
    By Dan Vollmer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-28-2014, 09:51 PM
  2. [SOLVED] Highlight range of cells - run macro - select last cell in range
    By chromachem in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-24-2012, 11:46 AM
  3. Select a range of cells and then copy them, and paste into other cells
    By Dynelor in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-24-2007, 04:03 PM
  4. How do you select a range of cells on another worksheet using the Cells property?
    By iterature in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-20-2007, 10:45 AM
  5. Select a range of cells
    By mattsgr1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-10-2007, 05:00 AM
  6. How to do this?:How to select a range of cells
    By Paul in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-28-2006, 11:25 PM
  7. [SOLVED] Compare a selected Range with a Named range and select cells that do not exist
    By PCLIVE in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-18-2005, 03:05 PM
  8. Select Range of Cells
    By programmingrookie in forum Excel General
    Replies: 2
    Last Post: 08-11-2005, 03:05 PM

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