Vba to tell me what cell in range has the most letters

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
2,676
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,
I'm trying to makea grid area where every cell is the same size,

I have 500 cells and keep finding when I resize some text in some cells is missing

is there a macro I could run that would tell me which cell has the longest amount of text?

Thanks

Tony
 

Some videos you may like

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

mumps

Well-known Member
Joined
Apr 11, 2012
Messages
10,097
Try:
Code:
Sub FindLength()
    Application.ScreenUpdating = False
    Dim rng As Range, cnt As Long, sAddr As String
    For Each rng In Range("[COLOR="#FF0000"]A1:J50[/COLOR]")
        If Len(rng) > cnt Then
            cnt = Len(rng)
            sAddr = rng.Address(0, 0)
        End If
    Next rng
    MsgBox ("The longest text is in cell " & sAddr)
    Application.ScreenUpdating = True
End Sub
Change the range (in red) to suit your needs.
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,122,230
Messages
5,594,947
Members
413,953
Latest member
Arthur1471

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top