How do I use the Indirect Function in Excel VBA to incorporate the equations in a VBA Macro Function

0 votes

(A7) value = JohnWinstonLennon

On the default Excel Worksheet, these equations function perfectly. In a run-on String like the one above, both equations indicate where the second and third capital letters should be placed.

I am trying to write them into a function with VBA, but I cannot figure out how to make the Indirect reference work in the function. Please, I Need Help!

=SMALL(FIND(0,SUBSTITUTE(A7,CHAR(ROW(INDIRECT("65:90"))),0)&0),2)  
=SMALL(FIND(0,SUBSTITUTE(A7,CHAR(ROW(INDIRECT("65:90"))),0)&0),3) 
Jan 19, 2023 in Others by Kithuzzz
• 38,000 points
1,048 views

1 answer to this question.

0 votes

Try this:

Sub Test()

Dim str As String: str = "JohnWinstonLennon"

With CreateObject("vbscript.regexp")
    .Global = True
    .Pattern = "[A-Z]"
    If .Test(str) Then
        Set matches = .Execute(str)
        For Each Match In matches
            Debug.Print Match.FirstIndex + 1
        Next
    End If
End With

End Sub
answered Jan 19, 2023 by narikkadan
• 63,600 points

Related Questions In Others

0 votes
1 answer

Excel-VBA - How to identify Target range (more than 1 cell) is deleted in a Worksheet_Change function?

You misunderstand the purpose of the function ...READ MORE

answered Sep 23, 2022 in Others by narikkadan
• 63,600 points
3,747 views
0 votes
1 answer

In excel how do I reference the current row but a specific column?

Put a $ symbol in front of ...READ MORE

answered Oct 15, 2022 in Others by narikkadan
• 63,600 points
1,944 views
0 votes
1 answer
0 votes
1 answer

Excel VBA : HOW TO PRINT THE TEXT IN A CELL (like Wrap Text)

Use a LineFeed character to create a ...READ MORE

answered Oct 27, 2022 in Others by narikkadan
• 63,600 points
1,037 views
0 votes
1 answer

Reversing Text to Columns in Excel/Calc

There are built-in functions that will allow ...READ MORE

answered Nov 15, 2022 in Others by narikkadan
• 63,600 points
531 views
0 votes
1 answer

How to arrange a string to display

It's a bad idea to use spaces ...READ MORE

answered Feb 3, 2023 in Others by narikkadan
• 63,600 points
608 views
0 votes
1 answer

Concatenate or TextJoin Same Cell Multiple Times based on Value in another Cell?

Use the REPT function: =REPT("ABC",4) => ABCABCABCABC ...READ MORE

answered Feb 18, 2023 in Others by narikkadan
• 63,600 points
658 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
1,238 views
0 votes
1 answer

How to use the INDIRECT function in Excel

Try this: =INDEX(INDIRECT($A$1&"!$1:$1048576"),MATCH($B$1,INDI ...READ MORE

answered Sep 29, 2022 in Others by narikkadan
• 63,600 points
911 views
0 votes
1 answer

How can I use a command button in excel to set the value of multiple cells in one click?

Try this: Private Scan As Integer Private Sub CommandButton1_Click() ...READ MORE

answered Oct 24, 2022 in Others by narikkadan
• 63,600 points
793 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP