Forum Discussion

Excel's avatar
Excel
Iron Contributor
Sep 01, 2022
Solved

Related to VBA code

Hello everyone, 

I want to calculate LEN function of Column K with the help of VBA code.

I have written the code for the function now i want result to displayed in n column can you help me to write code for autofill ?

 

Here is a attached screenshot :

 

Please help to what VBA code should i write to autofill it ?

  • Excel 

    Try this:

    Sub Test()
        Dim m As Long
        m = Range("K" & Rows.Count).End(xlUp).Row
        With Range("N2:N" & m)
            .Formula = "=LEN(K2)-LEN(SUBSTITUTE(K2,"","",""""))"
            .Value = .Value
        End With
    End Sub

5 Replies

  • Excel 

    Try this:

    Sub Test()
        Dim m As Long
        m = Range("K" & Rows.Count).End(xlUp).Row
        With Range("N2:N" & m)
            .Formula = "=LEN(K2)-LEN(SUBSTITUTE(K2,"","",""""))"
            .Value = .Value
        End With
    End Sub
    • Excel's avatar
      Excel
      Iron Contributor

      HansVogelaar 

       

      Hello Sir, 

       

      How to Autosum of JAN, FEB, MAR and TOTAL EXPENSES of every sheetwith the help of VBA code ?

       

      Please help...

       

      Here is a attached file...

       

       

      • Excel 

        You have asked very similar questions when you were active as Zan or Zain.

        Look through your older discussions, you'll find the code you need.

Resources