Skip to main content

Posts

Showing posts from November, 2017

How to find text in a worksheet and saving the row & column number where it is first found - Excel VBA

  How to find text in a worksheet and saving the row & column number where it is first found - Excel VBA   Sub Find_Text_Get_ROWS_COlumns()          Dim sText As String     Dim FindRow As Range     With ThisWorkbook.Sheets("Data")         sText = "Hello"         Set FindRow = .UsedRange.Find(What:=sText, LookIn:=xlValues)         MsgBox FindRow.Row         MsgBox FindRow.Column     End With End Sub

VBA - UI Automation Sample code:

VBA Reference to be added: VBA - UI Automation Project sample code Dim MyElement As UIAutomationClient.IUIAutomationElement Dim MyElement1 As UIAutomationClient.IUIAutomationElement 'Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Public Enum oConditions    eUIA_NamePropertyId    eUIA_AutomationIdPropertyId    eUIA_ClassNamePropertyId    eUIA_LocalizedControlTypePropertyId End Enum Sub Test() Dim AppObj As UIAutomationClient.IUIAutomationElement Dim oInvokePattern As UIAutomationClient.IUIAutomationInvokePattern Dim oAutomation As New CUIAutomation ' the UI Automation API\ Dim oPattern As UIAutomationClient.IUIAutomationLegacyIAccessiblePattern Set AppObj = WalkEnabledElements("BTB Portal 3.0 KA") Set MyElement = AppObj.FindFirst(TreeScope_Children, PropCondition(oAut