jeudi 15 février 2018

VBA Filter using checkboxes in Excel?

I'm new to VBA in Excel and trying to build a menu that will allow users to enter filter criteria using checkboxes. In this case, filter by states. Everything works fine when there is only one state selected, but multiple states clears the filter. The code I'm using to build the filter criteria string is below. I've tried adding additional quotes ("AL", "AK") but that clears the filter when only a single state is selected. Any suggestions would be greatly appreciated.

If Sheets("Menu").ckAL.Value = True Then
    strCriteria = strCriteria & ", AL"

End If

If Sheets("Menu").ckAK.Value = True Then
    strCriteria = strCriteria & ", AK"

End If

strCriteria = Mid(strCriteria, 2)

ActiveSheet.Range("$A$4:$AR$16998").AutoFilter Field:=3, Criteria1:=Array(strCriteria), Operator:=xlFilterValues

Thanks.

Bruce




disabling tkinter checkbox without greyout

Is there a method of disabling a tkinter checkbox without it becoming grey?

currently I am doing this: CB = tk.Checkbutton(master, state = DISABLED)




Trying to add values from a check box into a progress bar

There's a cool graphic to display progress. First crack to change the input from text field to checkbox was was something like this.

Code:

$(document).ready(function($) {
   var sum = 0;

   $("input:checkbox").click(function() {
       sum = 0;
       $("input:checkbox:checked").each(function(idx, elm) {
           sum += parseInt(elm.value, 10);
       });

       return sum  
   });
});

such that there are 10 checkboxes each one representing 10% completion of a task and the combined checkboxes leads to 100% how would you modify this? https://codepen.io/junebug12851/pen/mJZNqN




Check box based filtering of SharePoint list

I have a SharePoint list with one of the column as "Status" that holds values like "Not Started", "In Progress", "Completed" and few more. I already have a Search box (JavaScript code in CEWP) where we can filter list items based on text string entered. It works fine. However, since the list is getting larger day by day, the search functionality is getting slower. Around 80% of the items in the list are with "Completed" status. So, we want to have a functionality where we can include or exclude the Completed items from search as required. Sometimes, we still need to perform a search including "Completed" items as well.

=> My goal is to have a check box labeled "Completed". The function of check box would be: *When Checked - The SharePoint list will Include "Completed" items (Other items with Status "Not Started", "In Progress" etc should be there always)

*When Unchecked - SharePoint list will Exclude "Completed" Items but keep others

Also, the search box I already have should continue to work.

I tried to search for this, however, couldn't find it. I am not very good with JavaScript, however, if someone can help with code that can directly be implemented on CEWP, it will be great.

Thanks in advance.




Selenium WebDriver Click skips some check boxes

This is a followup question to this:

WebDriver element found, but click returns nothing

But the issue is so specific to my case that I cant find an answer. I am running the below code in which after clicking on a few drop down menu items I need to make selections on state, districts and so on. I loop through different selections under 'State' item. I would also like the Road Wise button checked. Here is my code:

from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
import time
import os

chromedriver = r"C:\Users\yuppal\chromedriver"
os.environ["webdriver.chrome.driver"] = chromedriver

browser = webdriver.Chrome(chromedriver)
browser.implicitly_wait(10)
browser.get("http://omms.nic.in")
browser.maximize_window()

progElem = browser.find_element_by_link_text("Progress Monitoring").click()
summElem = browser.find_element_by_link_text("Physical and Financial Project Summary").click()


stateElem = browser.find_element_by_xpath("//select[@name='StateCode']")
state_options = stateElem.find_elements_by_tag_name("option")

del state_options[0]

def select_option(xpath, text):
    elem = browser.find_element_by_xpath(xpath)
    Select(elem).select_by_visible_text(text)

for option in state_options:

        select_state = Select(stateElem).select_by_value(option.get_attribute("value"))
        # Select the district.
        select_option("//select[@name='DistrictCode']","All Districts")   
        # Select the block.
        select_option("//select[@name='BlockCode']","All Blocks")   
        # Select the year.
        select_option("//select[@name='Year']","All Years")
        # Select the batch.
        select_option("//select[@name='Batch']","All Batches")
        # Select the funding agency.
        select_option("//select[@name='FundingAgency']","Regular PMGSY")

        # Check the road wise box.
        time.sleep(10)
        checkElem = WebDriverWait(browser, 120).until(EC.element_to_be_clickable((By.XPATH, "//input[@title='Road Wise']")))
        browser.execute_script("arguments[0].click();", checkElem)

        # Click on the view button.
        time.sleep(10)
        browser.find_element_by_xpath("//input[@type='button']").click()



        # Switch to a new frame.
        time.sleep(10)
        frame = browser.find_element_by_xpath("//div[@id='loadReport']/iframe")
        browser.switch_to.default_content()
        #browser.switch_to.frame(frame)
        WebDriverWait(browser, 120).until(EC.frame_to_be_available_and_switch_to_it(frame))
        #browser.switch_to.frame(browser.find_element_by_xpath("//*[@id='loadReport']/iframe"))

        # click on the save button
        time.sleep(10)
        WebDriverWait(browser, 120).until(EC.element_to_be_clickable((By.XPATH, "//a[@title='Export drop down menu']"))).click()

        # Within the save button, Click on the "Excel" option.
        time.sleep(10)
        WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, "//div/a[@title='Excel']"))).click()


        # Switch back to the main content.
        time.sleep(20)
        browser.switch_to.default_content()

My issue is the 'Road Wise' checkbox gets clicked for some iterations and not for others. I checked the html code and it is the same for all check boxes. I thought the 'view' button gets clicked before the road wise button is clickable. I put some waiting period before both road wise and view buttons. But doesn't seem to help. I would appreciate any help!

Yogesh




Spinbox checkable: how to handle it with only one labeled checkbox?

I'm working on a project where I'd like to have a checkable Spinbox and a checkbox that allows me to set the Spinbox checked (I can write in it) and uncheked(I can't write in it). I succeed in having such a checkbox, the problem is that when I've created the Spinbox and I set it "checkable", a mini checkbox came out by default. So the situation is that I have two checkbox : one created by me, labeled and nevertheless desired, and one created by default. I'd like to know if there is a way to either delete the checkbox created by default or labeled it, in order to delete the one that I've created. I attach a print screen of the situation to help my pretty bad english. Thank's in advance.enter image description here




Using checkboxes to select tables

I am working on a school project, but I got stuck on this part where I am trying to implement checkboxes as a user input. I have a database with 17 tables each with a number of columns, ranging from 3 up to 21 columns. Some one else in my group created a website as a user interface. On this website we have 17 checkboxes, each with a table name. The goal is for the user to be able to select a few checkboxes, click submit and that then these tables will appear (inner)joined together.

I have the code, but at the moment I tried it with a whole bunch of IF statemets which I knew wouldn't work, and it doesn't :)

Can anybody help me?

User interface

At the moment my code is about 500 lines as there are some other tables that I am working with as well. I don't really know what part of the code is neccessary for this part, but here is the PHP before the HTML code:

<?php
$con=mysqli_connect("localhost","root","","test_terma");

$sql = "SELECT * FROM pcf
    INNER JOIN cur ON pcf.pcf_name = cur.cur_pname
    ";

  $result = mysqli_query($con, $sql);

if(isset($_POST['search']))
 {
    $searchq = $_POST['search'];
    $sql = "SELECT * FROM pcf
            INNER JOIN cur ON pcf.pcf_name = cur.cur_pname
            WHERE pcf_name LIKE '%$searchq'";

  $result = mysqli_query($con, $sql);
 }
if(isset($_POST['table']))
 {
    $sql = "SELECT * FROM pcf";
    $result = mysqli_query($con, $sql);
 }
?>

Maybe it is also useful to have the checkbox code in HTML:

<html>

<head>
   <meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1">
<title>Website</title>
<link rel="stylesheet" href="Stylesheet.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  <script src="JavaScript.js"></script>
</head>

<body>
<img class="resize" src="Terma.jpg" alt="">
<hr width="100%" color="#252525" size="1px">

<div class="row">
    <div class="search" style="background-color: #fff;">
        <h1>Search</h1>
        <div class="searchbar">
            <form class="example" action="terma_f.php" method="post">
                <input type="text" size="20" placeholder="Search" name="search">
                <button type="submit" class="btn btn-default">
                <i class="fa fa-search"></i>
                </button><h1>Tables</h1>
                <h4>
                <input type="checkbox" name="PCF" value="PCF">PCF<br>
                <input type="checkbox" name="CUR" value="CUR">CUR<br>
                <input type="checkbox" name="LGF" value="LGF">LGF<br>
                <input type="checkbox" name="MCF" value="MCF">MCF<br>
                <input type="checkbox" name="CAF" value="CAF">CAF<br>
                <input type="checkbox" name="CAP" value="CAP">CAP<br>
                <input type="checkbox" name="PLF" value="PLF">PLF<br>
                <input type="checkbox" name="VPD" value="VPD">VPD<br>
                <input type="checkbox" name="PID" value="PID">PID<br>
                <input type="checkbox" name="TPCF" value="TPCF">TPCF<br>
                <input type="checkbox" name="GRPK" value="GRPK">GRPK<br>
                <input type="checkbox" name="GRP" value="GRP">GRP<br>
                <input type="checkbox" name="GRPA" value="GRPA">GRPA<br>
                <input type="checkbox" name="TXF" value="TXF">TXF<br>
                <input type="checkbox" name="TXP" value="TXP">TXP<br>
                <input type="checkbox" name="OCF" value="OCF">OCF<br>
                <input type="checkbox" name="OCP" value="OCP">OCP<br></h4>
            </form>
        </div>
    </div>

    <div class="divider" style="background-color: #000;">
        <h3> </h3>
    </div>

    <?php
        if(mysqli_num_rows($result) > 0)
        {
?>