Tuesday, December 25, 2018

How to count and sum cells by color in Excel 2016, 2013 and 2010


Suppose you have a table listing your company's orders where the cells in the Delivery column are colored based on their value - "Due in X Days" cells are orange, "Delivered" items are green and "Past Due" orders are red.


What we want now is automatically count cells by color, i.e. calculate the number of red, green and orange cells in the worksheet. As I explained above, there is no straightforward solution to this task.  So, move on with the 5 quick steps below and you will know the number and sum of your color cells in a few minutes.
1.     1. Open your Excel workbook and press Alt+F11 to open Visual Basic Editor (VBE).
2.     2. Right-click on your workbook name under "Project-VBAProject" in the right hand part of the screen, and then choose Insert > Module from the context menu.
3.     3. Add the following code to your worksheet:
Function GetCellColor(xlRange As Range)
    Dim indRow, indColumn As Long
    Dim arResults()

    Application.Volatile

    If xlRange Is Nothing Then
        Set xlRange = Application.ThisCell
    End If

    If xlRange.Count > 1 Then
      ReDim arResults(1 To xlRange.Rows.Count, 1 To xlRange.Columns.Count)
       For indRow = 1 To xlRange.Rows.Count
         For indColumn = 1 To xlRange.Columns.Count
           arResults(indRow, indColumn) = xlRange(indRow, indColumn).Interior.Color
         Next
       Next
     GetCellColor = arResults
    Else
     GetCellColor = xlRange.Interior.Color
    End If
End Function

Function GetCellFontColor(xlRange As Range)
    Dim indRow, indColumn As Long
    Dim arResults()

    Application.Volatile

    If xlRange Is Nothing Then
        Set xlRange = Application.ThisCell
    End If

    If xlRange.Count > 1 Then
      ReDim arResults(1 To xlRange.Rows.Count, 1 To xlRange.Columns.Count)
       For indRow = 1 To xlRange.Rows.Count
         For indColumn = 1 To xlRange.Columns.Count
           arResults(indRow, indColumn) = xlRange(indRow, indColumn).Font.Color
         Next
       Next
     GetCellFontColor = arResults
    Else
     GetCellFontColor = xlRange.Font.Color
    End If

End Function

Function CountCellsByColor(rData As Range, cellRefColor As Range) As Long
    Dim indRefColor As Long
    Dim cellCurrent As Range
    Dim cntRes As Long

    Application.Volatile
    cntRes = 0
    indRefColor = cellRefColor.Cells(1, 1).Interior.Color
    For Each cellCurrent In rData
        If indRefColor = cellCurrent.Interior.Color Then
            cntRes = cntRes + 1
        End If
    Next cellCurrent

    CountCellsByColor = cntRes
End Function

Function SumCellsByColor(rData As Range, cellRefColor As Range)
    Dim indRefColor As Long
    Dim cellCurrent As Range
    Dim sumRes

    Application.Volatile
    sumRes = 0
    indRefColor = cellRefColor.Cells(1, 1).Interior.Color
    For Each cellCurrent In rData
        If indRefColor = cellCurrent.Interior.Color Then
            sumRes = WorksheetFunction.Sum(cellCurrent, sumRes)
        End If
    Next cellCurrent

    SumCellsByColor = sumRes
End Function

Function CountCellsByFontColor(rData As Range, cellRefColor As Range) As Long
    Dim indRefColor As Long
    Dim cellCurrent As Range
    Dim cntRes As Long

    Application.Volatile
    cntRes = 0
    indRefColor = cellRefColor.Cells(1, 1).Font.Color
    For Each cellCurrent In rData
        If indRefColor = cellCurrent.Font.Color Then
            cntRes = cntRes + 1
        End If
    Next cellCurrent

    CountCellsByFontColor = cntRes
End Function

Function SumCellsByFontColor(rData As Range, cellRefColor As Range)
    Dim indRefColor As Long
    Dim cellCurrent As Range
    Dim sumRes

    Application.Volatile
    sumRes = 0
    indRefColor = cellRefColor.Cells(1, 1).Font.Color
    For Each cellCurrent In rData
        If indRefColor = cellCurrent.Font.Color Then
            sumRes = WorksheetFunction.Sum(cellCurrent, sumRes)
        End If
    Next cellCurrent

    SumCellsByFontColor = sumRes
End Function



4.     4. Save your workbook as "Excel Macro-Enabled Workbook (.xlsm)".
If you are not very comfortable with VBA, you can find the detailed step-by-step instructions and a handful of useful tips in this tutorial: How to insert and run VBA code in Excel.
5.     5. Now that all "behind the scenes" work is done for you by the just added user-defined function, choose the cell where you want to output the results and enter the CountCellsByColor function into it:
CountCellsByColor(rangecolor code)
In this example, we use the formula =CountCellsByColor(F2:F14,A17) where F2:F14 is the range containing color-coded cells you want to count and A17 is the cell with a certain background color, a red one in our case.
In a similar way, you write the formula for the other colors you want to count, yellow and green in our table.
If you have numerical data in colored cells (e.g. the Qty. column in our table), you can add up the values based on a certain color by using an analogous SumCellsByColor function:
SumCellsByColor(rangecolor code)

As demonstrated in the screenshot above, we used the formula =SumCellsByColor(D2:D14,A17) where D2:D14 is the range and A17 is the cell with a color pattern.
In a similar way you can count cells and sum cells' values by font color using the CountCellsByFontColor and SumCellsByFontColor functions, respectively.

Note: If after applying the above mentioned VBA code you would need to color a few more cells manually, the sum and count of the colored cells won't get recalculated automatically to reflect the changes. Please don't be angry with us, this is not a bug of the code : )
In fact, it is the normal behavior of all Excel macros, VBA scripts and User-Defined Functions. The point is that all such functions are called with a change of a worksheet's data only and Excel does not perceive changing the font color or cell color as a data change. So, after coloring cells manually, simply place the cursor to any cell and press F2 and Enter, the sum and count will get updated. The same applies to the other macros you will find further in this article.
Sum by color and count by color across the entire workbook
The VB script below namely counts and sums the cells of a certain color in all worksheets of the workbook. So, here comes the code:
Function WbkCountCellsByColor(cellRefColor As Range)
    Dim vWbkRes
    Dim wshCurrent As Worksheet
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    vWbkRes = 0
    For Each wshCurrent In Worksheets
       wshCurrent.Activate
       vWbkRes = vWbkRes + CountCellsByColor(wshCurrent.UsedRange, cellRefColor)
    Next
    Application.ScreenUpdating = True
    Application.Calculation = xlCalculationAutomatic
    WbkCountCellsByColor = vWbkRes
End Function
Function WbkSumCellsByColor(cellRefColor As Range)
    Dim vWbkRes
    Dim wshCurrent As Worksheet
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    vWbkRes = 0
    For Each wshCurrent In Worksheets
       wshCurrent.Activate
       vWbkRes = vWbkRes + SumCellsByColor(wshCurrent.UsedRange, cellRefColor)
    Next
    Application.ScreenUpdating = True
    Application.Calculation = xlCalculationAutomatic
    WbkSumCellsByColor = vWbkRes
End Function
You use this macro in the same manner as the previous code and output the count and sum of the colored cells with the help of the following formulas, =WbkCountCellsByColor() and =WbkSumCellsByColor(), respectively. Simply enter either formula in any empty cell on any sheet without defining a range, specify the address of any cell of the needed color in brackets, e.g. =WbkSumCellsByColor(A1), and the formula will display the sum of all the cells shaded with the same color in your workbook.
Custom functions to get a cell's background color, font color and color code
Here you will find a summary of all the functions we've used in this example as well as a couple of new ones that retrieve color codes.
Note: Please remember that all of these formulas will work only if you have added the user-defined function to your Excel workbook as demonstrated earlier in the article.
Functions to count by color:
o   CountCellsByColor(range, color code)- counts cells with the specified background color.
In the above example, we used the following formula to count cells by color =CountCellsByColor(F2:F14,A17) where F2:F14 is the selected range and A17 is the cell with the needed background color. You can use all other formulas listed below in a similar way.
o   CountCellsByFontColor(range, color code) - counts cells with the specified font color.
Formulas to sum by color:
o   SumCellsByColor(range, color code) - calculates the sum of cells with a certain background color.
o   SumCellsByFontColor(range, color code) - calculates the sum of cells with a certain font color.
Formulas to get the color code:
o   GetCellFontColor(cell) - returns the color code of the font color of a specified cell.
o   GetCellColor(cell) - returns the color code of the background color of a specified cell.

Well, counting cells based on color and getting the sum of colored cells was pretty easy, wasn't it? Of course if you have that little VBA gem that makes the magic happen : ) But what if you do not color cells manually and rather use conditional formatting, as we discussed in these two articles How to change the background color of cells and How to change a row's color based on cell value?
How to count by color and sum cells colored using conditional formatting
If you have applied conditional formatting to color cells based on their values and now you want to count cells by color or sum the values in colored cells, I have bad news - there is no universal user-defined function that would sum by color or count color cells and output the resulting numbers directly in the specified cells. At least, I am not aware of any such function, alas : (
Of course, you can find tons of VBA code on the Internet that attempts to do this, but all those codes (at least the examples I've come across, do not process conditional formatting such as "Format all cells based on their values", "Format only top or bottom ranked values", "Format only values that are above or below average", "Format only unique or duplicate values". Besides that nearly all those VBA codes have a number of  limitations because of which they may not work correctly with certain workbooks or data types. All in all, you can try your luck and google for an ideal solution and if you happen to find one, please do come back and post your finding here!
The VBA code below overcomes the above mentioned limitations and works in Microsoft Excel 2010, Excel 2013 and Excel 2016 spreadsheets with all types of condition formatting . As a result, it displays the number of colored cells and the sum of values in those cells, no matter which type of conditional formats are used in a sheet.
Sub SumCountByConditionalFormat()
    Dim indRefColor As Long
    Dim cellCurrent As Range
    Dim cntRes As Long
    Dim sumRes
    Dim cntCells As Long
    Dim indCurCell As Long
    cntRes = 0
    sumRes = 0
    cntCells = Selection.CountLarge
    indRefColor = ActiveCell.DisplayFormat.Interior.Color
    For indCurCell = 1 To (cntCells - 1)
        If indRefColor = Selection(indCurCell).DisplayFormat.Interior.Color Then
            cntRes = cntRes + 1
            sumRes = WorksheetFunction.Sum(Selection(indCurCell), sumRes)
        End If
    Next
   MsgBox "Count=" & cntRes & vbCrLf & "Sum= " & sumRes & vbCrLf & vbCrLf & _
        "Color=" & Left("000000", 6 - Len(Hex(indRefColor))) & _
        Hex(indRefColor) & vbCrLf, , "Count & Sum by Conditional Format color"
End Sub
How to use the code to count colored cells and sum their values
7.     Add the above code to your worksheet as explained in the first example.
8.     Select a range or ranges where you want to count colored cells or/and sum by color if you have numerical data.
9.     Press and hold Ctrl, select one cell with the needed color, and then release the Ctrl key.
10. Press Alt+F8 to open the list of macros in your workbook.
11. Select the SumCountByConditionalFormat macro and click Run.
As a result, you will see the following message:
For this example, we selected the Qty. column and got the following numbers:
§  Count is the number of the cells with a particular color, a reddish color in our case that marks "Past Due" cells.
§  Sum is the sum of values of all red cells in the Qty. column, i.e. the total number of "Past Due" items.
§  Color is the Hexadecimal color code of a selected cell, D2 in our case.
Sample workbook for download
If you have any difficulties with adding the scripts to your Excel workbooks, such as compilation errors, formulas not working and so on, please download this sample workbookwith the CountCellsByColor and SumCellsByColor functions ready for use and try them on your data.

Sunday, October 14, 2018

How to Change Hwawei HiSuite Language ?

By default the software installation language were using the computer default language setting. To change it to the English language, simply follow this method:



  • Go to: C:\Users\<your_username>\AppData\Local\HiSuite\userdata\
  • Open file UserSetting.xml and edit the file using your favorite text editor.
  • Overwrite the active language with your selective language like the picture below.
 
  •  Make sure to keep it in padded with underscore. eg: _en-us
  • To view the list of available language, go to C:\Program Files\HiSuite and open the LangAreaForShort.xml with your favorite text editor.
  • Try to run the HiSuite software again and see the changing should work.


Tuesday, October 2, 2018

How to Minimize a program to the system tray in Windows 7/8/10 ?

Minimize a program to the system tray in Windows 7/8/10  

Download the program: it's called "RBTray", and it is both free (nothing to pay, ever), and open-source (the code of the program is available for anyone to see). There is not even an installer, so no settings on your computer will be changed, and the registry will be left alone! On the download page, click on the first RBTray link, for the current version,

Save the zip archive anywhere you want: once it's finished downloading, double-click on it to view its content. It comes in two variants: 32-bit and 64-bit. Pick the one that matches your Windows version. In doubt, either learn how to easily find out if you have 32-bit or 64-bit Windows, or get the 32-bit version, which works on all versions and editions of Windows XP/Vista and 7/8/10.


Double-click on the folder that corresponds to your architecture: each one contains just two files: the executable (program that runs in the background), and a DLL file. Select both, then copy and paste them in a folder of your choice - out of the way is fine, since you'll probably use a shortcut to launch RBTray anyway. Double-click on the exe file to run RBTray: see the following tutorial if you get the "This publisher could not be verified" warning message.

RBTray a perfect candidate to automatically run at startup, when Windows boots. From now on, click normally on the minimize button to minimize programs to the taskbar. And right-click on the minimize button to hide the program window and add an icon for it in the system tray (notification area, next to the system clock). If needed, configure Windows to always show the icon.

Thursday, September 6, 2018

How to Use Pendrive as RAM in Window 7, 8 and 10


·        Plug your Pendrive to Computer. (Make sure your pendrive class between 6-10. High Class means 
·        performance and speed.)
·        Right Click on your Pendrive icon and select Properties.



·        Now a new Window Open , Select Readyboost Tab and Select use this device option. Choose the ram size and select you ram value. 
·        Now you can turn your pen drive into a ram from this two steps procedure.
 How You Use This Feature:
·        PC Games Needs more RAM so use this trick.
·        Software Like Video Editing
·        If you Experience Slow PC Performance


Thursday, August 30, 2018

How to Download Facebook Videos to iPhone



Putting all the criticisms aside, Facebook is one of the biggest platforms where users can chat with one another, share photos and videos, contact businesses, and do much more.
If you’ve been using Facebook for a while, you must have come across an interesting or funny video that you wanted to save to your iPhone. Unfortunately, Facebook does not provide a feature to download and save videos to your iPhone so that you can watch it later or share it with other apps.
Despite this restriction, there are still a number of methods that will enable you to save videos from Facebook directly to your iPhone. In this tutorial, we will show you the three different methods that will help you solve this problem. You can either use an online Facebook downloader, sideload an app called Facebook++ which provides video downloading capability, or take advantage of a video downloader software. So without further ado, let’s get started.

Method 1: Using an Online Facebook Downloader

There are many online video downloaders out there that allow you to download videos from Facebook. One such example is FBDownload that lets you download videos from Facebook with ease. Alongside this, you also need a browser that supports file downloads, such as DManager.
Step 1: Download DManager app from the App Store. If you can’t find it, then click this link to view the app in App Store.
Step 2: If you already have the link of the video that you want to download, then you can skip this step. Otherwise, open the Facebook app on your iPhone and go to the video that you want to download. Tap on the Share button in the bottom right corner, then press Copy Link.
Step 3: Open the DManager app and type fbdownload.io in the URL bar.
Step 4: After the website has loaded, paste the video’s link into the search box, then press the Download button.
download facebook video to iphone
Step 5: Once the downloads are generated, a table is displayed containing all the available video resolutions and their download links. Tap and hold on a download button, then choose Download from the pop-up menu that appears.
download facebook video to iphone
Step 6: The app begins to download the video. You can view its progress by going to the Downloads tab. Once the video has been downloaded, swipe it to the right and choose Action > Open In. From the Share Sheet, select Save Video. That’s it, the video is now saved to your iPhone’s Camera Roll.
download facebook video to iphone

Method 2: Download and Install Facebook++

Facebook++ is an unofficial app that brings a number of new features to Facebook, including the ability to download videos. You can sideload this app via Cydia Impactor and use it on your iPhone.
Note: You have to first delete the original Facebook app before installing Facebook++, otherwise the installation will show an error.
Step 1: Download the Facebook++ IPA from here. Additionally, download Cydia Impactor for Mac, Windows, or Linux.
Step 2: Connect your iPhone to your computer, then open Cydia Impactor.
Step 3: Drag and drop the Facebook++ file onto Cydia Impactor.
Step 4: You’ll be asked to enter your Apple ID and password. This is sent to Apple to generate a signing certificate.
Step 5: Cydia Impactor will begin installing Facebook++ onto your device. Once done, you should see Facebook’s icon on your iPhone’s Home screen. Before opening it, go to Settings > General > Profiles (or ‘Device Management’).
Step 6: Open the profile labeled with your Apple ID, then tap on the Trust button.
Step 7: Now open Facebook++ app and go to the video that you want to download. You should now see a Save button that will download the video to your iPhone’s Camera Roll.

Method 3: Using a Video Downloader Software

There are tons of video downloading software that allow you to download videos from a number of social media websites to your computer. One such software is 4KDownload which supports macOS, Windows, and Linux. Using this, you can download videos from Facebook to your computer, and then transfer it to your iPhone using either AirDrop or a file transfer software for iOS.
These are the three different methods for downloading and saving videos from Facebook to your iPhone’s Camera Roll. Each has its own benefits and drawbacks, but my preferred method is the first one as it works on any device and operating system, is available for free and can be accessed easily from anywhere using a browser.
What’s your favorite method of downloading Facebook videos? Let me know in the comments below.

Monday, August 27, 2018

How to Restore a Missing Battery Icon in Windows 10 ?


You log on to Windows 10 with your laptop and notice that the battery icon is conspicuously absent from your taskbar. You click the arrow which shows all your hidden icons, and there's no power indicator there either. It's hard to say why this little white symbol goes AWOL -- it happened to me after a recent Windows update -- but fortunately, it's easy to fix.  
Here's how to restore a missing battery icon in Windows 10.

 
1.      Right click on the taskbar and select Settings.

2.     Click "Turn system icons on or off."

3.     Toggle Power to on.

Your battery icon should appear in the system tray again.



Monday, August 13, 2018

How to fix Bluetooth stops working, requires Phone reboot ?

I have been searching for this for long time till i got the solution you need to  checked if Bluetooth Scanning is off? To check, go to Settings> Location> tap 3 dots> Scanning> toggle off Bluetooth Scanning if it is on and  that it is it will be working again . Reset as well your Bluetooth device is an option 

Thursday, June 21, 2018

How to add 'Open OpenShell and Command Window Here' to Windows 10 Context Menu


This how-to focuses on bringing back the option to launch the command prompt from the right-click Windows 10 context menu.
Microsoft has hidden the command prompt from the Power User menu (Windows key + X), file menu for file explorer, and the extended or right-click Windows 10 context menu context menu (Shift + Right-click). Here's how to bring back the option to launch the command prompt from the right-click Windows 10 context menu.
Adding ‘Open PowerShell window here’ Option to the Windows 10 Context Menu of a Folder
 
Step One: Press Windows key and + R from the keyboard to open the Run command. Type regedit and then hit enter from the keyboard to open the registry.
Step Two: Go to the following path:
HKEY_CLASSES_ROOT\Directory\shell\cmd
Right-click the cmd key. Scroll to Permissions and then click it.
Step Three: Click Advanced.
Step Four: Click the Change link.
Step Five: Type your user account name and click ‘Check Names’ to verify it. Click OK when you are done.
Step Six: Check ‘Replace owner on subcontainers and objects’. Click Apply and then OK.
Step Seven: In ‘Permissions for cmd’ window, select the Administrator account. Check Allow for full control option. Click Apply and then OK.
Step Eight: Inside the cmd key (right window), right click HideBasedOnVelocityId and then click Rename.
Step Nine: Rename the DWORD from HideBasedOnVelocityId to ShowBasedOnVelocityId, then hit Enter from the keyboard.
You are done. When you press shift from the keyboard and then right-click on any folder, you will have the ‘Open PowerShell window here’ option on the Windows 10 Context Menu.
 Adding ‘Open command window here’ Option to the Context Menu of Background
  Here are the few steps you need to take:
Step One: Press Windows key + R simultaneously to open the Run command. Type regedit and hit enter from the keyboard to open the registry.

Step Two: Go to the following path:
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd
Step Three: Right-click the cmd key and then click Permissions.
Step Four: Click Advanced.
Step Five: Click the change link on top of the window in front of owner option.

Step Six: Type your user account name and click ‘Check Names’ to verify it. Click OK when you are done.
Step Seven: Check ‘Replace owner on subcontainers and objects’ option. Click Apply and then OK.

Step Eight: In permissions window, choose the administrator user. Check Allow for Full Control option, click Apply and then OK.
Step Nine: Inside the cmd key (right window), right-click the HideBasedOnVelocityId DWORD and then click Rename.

Step Ten: Change the DWORD name from HideBasedOnVelocityId to ShowBasedOnVelocityId and press Enter from the keyboard.

That’s all. When you press shift and right-click anywhere on your windows background, you will have an option of ‘Open command window here’ as shown in the following screenshot from Windows 10.




Wednesday, June 13, 2018