Option Explicit Sub PrintCellsWithERR() Dim ws As Worksheet Dim rangetoCheck As Range, sCell As Range For Each ws In ActiveWorkbook.Worksheets Set rangetoCheck = ws.UsedRange For Each sCell In rangetoCheck If IsError(sCell.Value) Then Debug.Print ws.Name & "==>" & sCell.Address End If Next sCell Next ws End Sub
Friendly Programming tutorials for beginners and professionals. Subscribe to join us now!
Search
Print or list formula from all Sheets in ActiveWorkbook
How to build Professional Excel Add-in. Excel Add-in Development course
Subscribe Now!
New videos every Weekend!
How to build Professional Excel Add-in. Excel Add-in Development course
Related links.
https://docs.microsoft.com/en-us/office/vba/api/excel.application.onkey
https://vbaa2z.blogspot.com/search?q=ribbonx
<!--Ribbon customization by Lung Pamai; Last Modified:--> <!--RIBBONX E01, E05--> <!--http://msdn.microsoft.com/en-us/library/dd909393(v=office.12).aspx--> <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"> <ribbon startFromScratch="false"> <tabs> <tab id="IDTab5" label="DEMO" insertAfterMso="TabHome"> <group id="IDGroup5" label="Connect"> <button id="IDButton5" label="label1" size="large" onAction="macro1" imageMso="ImportMoreMenu" /> </group> </tab> <tab idMso="TabHome"> <group id="Group5" label="Custom Utilities"> <toggleButton id="toggleButton" imageMso="SizeToControlHeightAndWidth" label = "Highlight Rows and Columns" size = "large" onAction = "ButtonToggled_click" /> </group> </tab> </tabs> </ribbon> </customUI>
GetKeyStateDeclare PtrSafe Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer Const VK_CONTROL As Integer = &H11
Add Control and Position Controls in UserForm Design Mode
Add Control and Position Controls in UserForm Design Mode
https://www.youtube.com/watch?v=csUhqCN0CBI
Option Explicit Sub addctrl_design_mode_v2() 't1-54;114;108;78 'T54, 60/42, T54 'Microsoft Visual Basic Applications Extensibility 5.3 Dim UFvbc As VBComponent Dim r As Long Set UFvbc = ThisWorkbook.VBProject.VBComponents("UserForm1") Dim cb As Control Dim t As Long, h&, w&, rowCnt&, ColCnt&, objLeft&, vGap&, objLeft_last&, totalColumns& Dim objRow_last As Long Dim TotalRows& t = 15 'top h = 10 'hieght w = 84 'width rowCnt = 1 ColCnt = 1 objLeft = 40 objLeft_last = 10 vGap = 1 objRow_last = 20 TotalRows = 10 totalColumns = 11 For r = 1 To (TotalRows * totalColumns) '(6 * 7) Set cb = UFvbc.Designer.Controls.Add("Forms.Label.1", "Label" & r, True) 'Set cb = UFvbc.Designer.Controls.Add("Forms.Textbox.1", "Textbox" & r, True) 't1_r1_c1 cb.Name = "t1_r" & rowCnt & "_c" & ColCnt cb.BackColor = &HC0C0C0 'vbGreen cb.Height = h cb.Width = w cb.Top = objRow_last '---------------------- If ColCnt = 1 Then cb.Left = objLeft objLeft_last = objLeft 'vGap = 1 Else cb.Left = objLeft_last + w + vGap objLeft_last = objLeft_last + w + vGap End If ColCnt = ColCnt + 1 '---------------------- If ColCnt = totalColumns + 1 Then ColCnt = 1 rowCnt = rowCnt + 1 objLeft_last = 10 objRow_last = objRow_last + h + vGap End If Set cb = Nothing Next r End Sub
Kill function sample codes
Deletes files from a disk. The example below uses .txt file but you may replace with any file types.
Kill MacID("C:\Users\LP\AppData\Local\Temp\TestFile.txt")
If you use the MacID function with Kill in Microsoft Windows, an error occurs. An error also occurs if you try to use Kill to delete an open file.
' Assume TESTFILE is a file containing some data.
Kill "C:\Users\LP\AppData\Local\Temp\TestFile.txt" ' Delete file.
' Delete all *.TXT files in the current directory.
Kill "C:\Users\LP\AppData\Local\Temp\*.TXT"
Simple video on how to create dynamic excel range using VBA
A simple video on how to create a dynamic excel range using VBA
Video Link: https://youtu.be/1ia8Imrk2kI
Also, check more dynamic range functions here
Sub Get_range_lr_lc_usedRange_Tst() 'find in used range 'last row 'last column '1st row in used range '& = long 'tested OK 'Manually replicate; CTRL + END Dim uLC& Dim uLR& Dim uFR& Dim uFC& uLR = ActiveSheet.UsedRange.Rows.Count uLC = ActiveSheet.UsedRange.Columns.Count uFR = ActiveSheet.UsedRange.Row uFC = ActiveSheet.UsedRange.Column Debug.Print uLR Debug.Print uLC Debug.Print uFR Debug.Print uFC End Sub
Sub LR_LC_forSpec() Dim lc As Long Dim lr As Long Dim LC_2 As Long 'Manually replicate; Select last cell/column and hit ctrl up / ctrl left lr = Sheets("Customer").Range("A" & Rows.Count).End(xlUp).Row 'lr in col a . Range("?" & ... ? = column name 'Range("A1048576").End(xlUp).Select lc = Cells(2, Columns.Count).End(xlToLeft).Column 'lc in row 2 . Cells(?,.... ? = Row No End Sub
Sub xCell() Dim xCellPosition As Range Dim xWord As String xWord = InputBox("", "Enter value to search", "Start typing the value to search...") Set xCellPosition = Cells.Find(What:=xWord, MatchCase:=True) If Not xCellPosition Is Nothing Then Debug.Print xCellPosition.Address 'utilize xCellPosition in ways. example below 'xCellPosition.Row 'xCellPosition.Column '... Else Debug.Print "Not found" End If End Sub Sub lr_in_selection() Dim lr As LoadPictureConstants lr = Selection.Row + Selection.Rows.Count - 1 Debug.Print lr End Sub Sub test_1() End Sub Sub Macro2() ' ' Macro2 Macro ' ' Range("A1").Select Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select ActiveWorkbook.Worksheets("Data").Sort.SortFields.Clear ActiveWorkbook.Worksheets("Data").Sort.SortFields.Add Key:=Range("B2:B36"), _ SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal ActiveWorkbook.Worksheets("Data").Sort.SortFields.Add Key:=Range("F2:F36"), _ SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal With ActiveWorkbook.Worksheets("Data").Sort .SetRange Range("A1:R36") .Header = xlYes .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With End Sub Sub sortmyData() Dim lr As Long Sheets("Customer").AutoFilterMode = False lr = Sheets("Customer").Range("A" & Rows.Count).End(xlUp).Row Sheets("Customer").Select ActiveWorkbook.Worksheets("Customer").Sort.SortFields.Clear ActiveWorkbook.Worksheets("Customer").Sort.SortFields.Add Key:=Range("B2:B" & lr), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal ActiveWorkbook.Worksheets("Customer").Sort.SortFields.Add Key:=Range("F2:F" & lr), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal With ActiveWorkbook.Worksheets("Customer").Sort .SetRange Range("A1:R" & lr) .Header = xlYes .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With End Sub Sub Macro4() ' ' Macro4 Macro ' ' ActiveCell.SpecialCells(xlLastCell).Select 'CTRL + end Range("M20").Select Selection.ClearContents Range("A1").Select ActiveWorkbook.Save ActiveCell.SpecialCells(xlLastCell).Select Range("F4").Select Range(Selection, Selection.End(xlToRight)).Select Columns("F:K").Select Range(Selection, Selection.End(xlToRight)).Select Selection.Clear Range("A1").Select ActiveWorkbook.Save ActiveCell.SpecialCells(xlLastCell).Select Range("E18").Select ActiveCell.FormulaR1C1 = "sdkf" Range("E18").Select Selection.ClearContents Range("A1").Select ActiveWorkbook.Save ActiveCell.SpecialCells(xlLastCell).Select Sheets("Topic").Select End Sub Sub copydata() Dim lr As Long Sheets("Customer").AutoFilterMode = False lr = Sheets("Customer").Range("A" & Rows.Count).End(xlUp).Row Sheets("Customer").Select Range("A1:R" & lr).Copy Sheets("Sheet1").Select Range("A1").PasteSpecial Paste:=xlPasteValues Selection.PasteSpecial Paste:=xlPasteFormats Application.CutCopyMode = False End Sub Sub Macro6() ' ' Macro6 Macro ' ' ActiveCell.SpecialCells(xlLastCell).Select Range(Selection, Cells(1)).Select Cells.Select Range("A35").Activate ActiveWorkbook.Save Range("A1").Select ActiveSheet.Previous.Select ActiveSheet.Previous.Select ActiveSheet.Previous.Select ActiveSheet.Previous.Select End Sub Sub dynamic_rng_test_1() Dim lr& Dim lc As Long '& 'Range("A1:R36") Range(Cells(1, 1), Cells(lr, lc)).Select End Sub
VSTO (Visual Studio Tools for Office)
Office Add-ins Platform
Professional UI/UX
PDF Automation using VBA
RibbonX First-Class Ribbon Customization
Word Automation using VBA
PPT Automation using VBA
Custom Menu using VBA
Sharepoint Automation Using VBA
Access Database Automation using Excel VBA
SQL Server Automation Using VBA
Web Automation using VBA
Excel Password Recovery/Reset
Errors and Solutions
Plug and Play Series
Office Quick Tips
Dark theme VBE
VBA to Loop Through All Sub-folders
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | sub DoFolder_Test() |
VBA UI UX-3: Advanced Autocomplete Suggestions, Predictive search for Excel UserForm
Subscribe Now!
New videos every Weekend!
Download project or source code from below link(s)
http://bit.ly/2TXGGqW
VBA UI UX-1: Build UI using Excel UserForm, Fields with watermark, transparent icons & Buttons
Subscribe Now!
New videos every Weekend!
Download project or source code from below link(s)
http://bit.ly/2GgZNE3
Extract any Web table to Excel in seconds using VBA - New 100% free with source code
Subscribe Now!
New videos every Weekend!
Please subscribe to my channel and also share with your friends.
RibbonX - Build First-Class UI Directly into App Ribbon
Subscribe Now!
New videos every Weekend!
Download project or source code from below link(s)
Resources
* OfficeCustomUIEditorSetup Download* 2.1 Parts
* 2.2 Elements
* 3.2 imageMso Table
* imageMSO Browser/Preview
Goto VSTO RibbonX - ALL
RibbonX - 01
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"> <ribbon startFromScratch="false"> <tabs> <tab idMso="TabHome"> <group id="Group5" label="Loader"> <button id="Button5" label="Upload to Database" size="normal" onAction="code1" imageMso="FilePublishAsWebPage"/> <button id="Button6" label="Run Reports" size="normal" onAction="code2" imageMso="Chart3DBarChart"/> <button id="Button7" label="Misc" size="normal" onAction="code3" imageMso="MacroConditions"/> <button id="Button8" label="Info" size="normal" onAction="code4" imageMso="Info"/> <button id="Button9" label="Help" size="normal" onAction="code5" imageMso="Help"/> </group> </tab> </tabs> </ribbon> </customUI>
RibbonX - 02
------------------------------------------ <?xml version="1.0" encoding="utf-8"?> <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"> <backstage> <tab id="customTab" label="Custom"> <firstColumn> <taskGroup id="customTaskGroup" label="Custom Task Group"> <category id="tgCategory1" label="Category One"> <task id="task1" label="Task 1" imageMso="FileOpen"/> <task id="task2" label="Task 2" imageMso="FileSave"/> <task id="task3" label="Task 3" imageMso="FileSaveAs"/> </category> </taskGroup> </firstColumn> </tab> </backstage> </customUI> ------------------------------------------ <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"> <ribbon startFromScratch="false"> <tabs> <tab id="customTab" label="Custom Tab"> <group id="customGroup" label="Custom Group"> <button id="customButton" label="Custom Button" imageMso="HappyFace" size="large" onAction="Callback" /> </group> </tab> </tabs> </ribbon> </customUI> ------------------------------------------ <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"> <ribbon> <tabs> <tab id="customTab" label="Contoso" insertAfterMso="TabHome"> <group idMso="GroupClipboard" /> <group idMso="GroupFont" /> <group id="customGroup" label="Contoso Tools"> <button id="customButton1" label="ConBold" size="large" onAction="conBoldSub" imageMso="Bold" /> <button id="customButton2" label="ConItalic" size="large" onAction="conItalicSub" imageMso="Italic" /> <button id="customButton3" label="ConUnderline" size="large" onAction="conUnderlineSub" imageMso="Underline" /> </group> <group idMso="GroupEnterDataAlignment" /> <group idMso="GroupEnterDataNumber" /> <group idMso="GroupQuickFormatting" /> </tab> </tabs> </ribbon> </customUI> ------------------------------------------ <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"> <commands> <command idMso="Bold" enabled="false"/> <command idMso="Save" onAction="MySave"/> </commands> </customUI> ------------------------------------------ <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"> <ribbon> <tabs> <tab idMso="TabInsert"> <group id="customGroup" label="Contoso" insertAfterMso="GroupIllustrations"> <button id="customButton" label="Document ID" size="large" imageMso="ListNumVal" onAction="insertDocID" /> </group> </tab> </tabs> </ribbon> </customUI> ------------------------------------------
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"> <ribbon> <tabs> <tab id="customTab" label="Contoso" insertAfterMso="TabHome"> <group idMso="GroupClipboard" /> <group idMso="GroupFont" /> <group id="customGroup" label="Contoso Tools"> <button id="customButton1" label="ConBold" size="large" onAction="conBoldSub" imageMso="Bold" /> <button id="customButton2" label="ConItalic" size="large" onAction="conItalicSub" imageMso="Italic" /> <button id="customButton3" label="ConUnderline" size="large" onAction="conUnderlineSub" imageMso="Underline" /> <gallery id="gallery" label="Gallery" itemWidth="88" itemHeight="68" size="large" imageMso="HappyFace" > <item id="item1" imageMso="FreezePanes" /> <item id="item2" imageMso="FreezePanes" /> <item id="item3" imageMso="FreezePanes" /> <item id="item4" imageMso="FreezePanes" /> </gallery> </group> <group idMso="GroupEnterDataAlignment" /> <group idMso="GroupEnterDataNumber" /> <group idMso="GroupQuickFormatting" /> </tab> </tabs> </ribbon> </customUI>
RibbonX - 03
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"> <ribbon startFromScratch="true"> <qat> <documentControls> <control idMso="CalculateNow" /> <control idMso="HyperlinkInsert" /> <button id="Button5" label="Upload to Database" onAction="code1" imageMso="Grouping"/> </documentControls> </qat> </ribbon> <backstage> <button idMso="FileSave" visible="false"/> <button idMso="FileSaveAs" visible="false"/> <button idMso="FileOpen" visible="false"/> <button idMso="FileClose" visible="false"/> <button idMso="ApplicationOptionsDialog" visible="false"/> <button idMso="FileExit" visible="false"/> <tab idMso="TabInfo" visible="false"/> <tab idMso="TabRecent" visible="false"/> <tab idMso="TabNew" visible="false"/> <tab idMso="TabPrint" visible="false"/> <tab idMso="TabShare" visible="false"/> <tab idMso="TabHelp" visible="false"/> <tab idMso="TabPublish" visible="false"/> <tab idMso="TabSave" visible="false"/> <tab idMso="TabOfficeStart" visible="false"/> <tab id="customTab" label="Custom"> <firstColumn> <taskGroup id="customTaskGroup" label="Custom Task Group"> <category id="tgCategory1" label="Category One"> <task id="task1" label="Task 1" imageMso="FileOpen"/> <task id="task2" label="Task 2" imageMso="FileSave"/> <task id="task3" label="Task 3" imageMso="FileSaveAs"/> </category> </taskGroup> </firstColumn> </tab> </backstage> </customUI>
RibbonX - 04
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"> <ribbon startFromScratch="false"> <contextualTabs> <tabSet idMso="TabSetChartTools"> <tab id="Tab1" label="Chart Utilities"> <group id="Group1" label="Chart Utilites"> <button id="Button5" label="Upload to Database" size="normal" onAction="code1" imageMso="FilePublishAsWebPage"/> <button id="Button6" label="Run Reports" size="normal" onAction="code2" imageMso="Chart3DBarChart"/> <button id="Button7" label="Misc" size="normal" onAction="code3" imageMso="MacroConditions"/> <button id="Button8" label="Info" size="normal" onAction="code4" imageMso="Info"/> <button id="Button9" label="Help" size="normal" onAction="code5" imageMso="Help"/> </group> </tab> </tabSet> <tabSet idMso="TabSetPivotTableTools"> <tab id="Tab1x" label="Pivot Utilities"> <group id="Group1x" label="Pivot Utilites"> <button id="Button5x" label="Upload to Database" size="normal" onAction="code1" imageMso="FilePublishAsWebPage"/> <button id="Button6x" label="Run Reports" size="normal" onAction="code2" imageMso="Chart3DBarChart"/> <button id="Button7x" label="Misc" size="normal" onAction="code3" imageMso="MacroConditions"/> <button id="Button8x" label="Info" size="normal" onAction="code4" imageMso="Info"/> <button id="Button9x" label="Help" size="normal" onAction="code5" imageMso="Help"/> </group> </tab> </tabSet> </contextualTabs> </ribbon> </customUI>
RibbonX - 05
https://docs.microsoft.com/en-us/openspecs/office_standards/ms-customui/700e4451-8706-40c5-8d7b-896e4ae21b69
RibbonX - 06
https://docs.microsoft.com/en-us/openspecs/office_standards/ms-customui/21312cb8-be0f-412c-8184-acd533a1410b
https://docs.microsoft.com/en-us/openspecs/office_standards/ms-customui/846e8fb6-07d3-460b-816b-bcfae841c95b
Contextual Tabs
- SmartArt Tools
- SmartArt Tools
- Chart Tools
- Chart Tools
- Drawing Tools
- Picture Tools
- Pivot Table Tools
- Pivot Table Tools
- Header & Footer Tools
- Table Tools
- Pivot Chart Tools
- Pivot Chart Tools
- Pivot Chart Tools
- Ink Tools
- Sparkline Tools
- Timeline Tools
- Slicer Tools
- Search Tools
- Query Tools
- Equation Tools
VSTO - Customize / Design Excel Ribbon using XML & .NET Tutorial Link: https://www.youtube.com/watch?v=C-F_hLt-goA XML code for reference below:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load"> <ribbon>
<contextualTabs> <tabSet idMso="TabSetChartTools"> <tab id="Tab1" label="Chart Utilities"> <group id="Group1" label="Chart Utilites"> <button id="Button5X" label="Change Chart Type" size="normal" onAction="CheckBoxtest" imageMso="FilePublishAsWebPage"/> <button id="Button6X" label="Change Color Def" size="normal" onAction="CheckBoxtest" imageMso="Chart3DBarChart"/> </group>
</tab> </tabSet>
</contextualTabs><tabs><tab id="Tab2" label="VSTO-XML"> <group id="Group1x" label="Version Info"> <labelControl id="Label1" getLabel="getLabelInfo"/> <labelControl id="Label2" getLabel="getLabelInfo"/> <labelControl id="Label3" getLabel="getLabelInfo"/> </group>
<group id="Group2" label="More Controls"> <button id="Button1" onAction="ShowTP" label="Show Task Pane" showImage="false"/> <button id="Button2" onAction="ShowUF" label="Show Win Form" showImage="false"/> </group>
<group id="Group3" label="Dropdown"> <dynamicMenu id="dynamic" label="Dynamic Menu" getContent="GetMenuContent"/> <dropDown id="dropDown" onAction="Location" label="City"> <item id="London" label="London"/> <item id="NewYork" label="New York"/> <item id="Delhi" label="Delhi"/> <button id="Budapest" label="Budapest" onAction="Budapest_bt"/> </dropDown> <labelControl id="Label4" label="Label4"/>
</group>
<group id="Group4" label="InputBox"> <editBox id="EditBox1" onChange="EditBox_TextChanged" getText="EditBoxGetText" label="Number 1" showImage="false"/> <editBox id="EditBox2" onChange="EditBox_TextChanged" getText="EditBoxGetText" label="Number 2" showImage="false"/> <editBox id="EditBox3" getText="EditBoxGetText" label="Total " showImage="false"/> <button id="Button4" onAction="CaclTotal" label="Cacl Total" showImage="false"/> </group>
<group id="Group5" label="Checkbox"> <checkBox id="CheckBox1" onAction="CheckBoxClck" getPressed="CheckBoxPressed" label="CheckBox1"/> <button id="Button5" onAction="CheckBoxtest" label="Check Box Test" showImage="false"/> <toggleButton id="ToggleButton1" label="ToggleButton1" showImage="false"/> </group>
</tab> </tabs> </ribbon> </customUI>
-
"Complete error message: The code in this project must be updated for use on 64-bit systems. Please review and update Decl...
-
Subscribe Now! New videos every Weekend! Like what I do? Donate Did I help you? Did one of my tutorials save you sometime? ...
-
This page has been migrated to: https://pamaitech.com/downloads/
-
Hello friends, In this series, I will be covering how to design a Professional User Interface using Microsoft Office Applications (start...
-
Subscribe Now! New videos every Weekend! Like what I do? Donate Did I help you? Did one of my tutorials save you sometime? ...