ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   determine if wrap text is set within a range (https://www.excelbanter.com/excel-programming/376230-determine-if-wrap-text-set-within-range.html)

dk

determine if wrap text is set within a range
 
is it possible to determine if a cell or multiple cells within a range
have the wrap text property set to true? And then to get the addresses
of those cells?

tia,
dk

Helmut Weber[_2_]

determine if wrap text is set within a range
 
Hi dk

like this:

Dim oCll As Range
For Each oCll In Selection.Cells
If oCll.WrapText = True Then
MsgBox oCll.Address
End If
Next

--
Greetings from Bavaria, Germany

I'm not an Excel-expert.
Just exploring strange territory.

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

dk

determine if wrap text is set within a range
 
Thanks

So it appears that Looping through the range is the only way?


"Helmut Weber" wrote:

Hi dk

like this:

Dim oCll As Range
For Each oCll In Selection.Cells
If oCll.WrapText = True Then
MsgBox oCll.Address
End If
Next

--
Greetings from Bavaria, Germany

I'm not an Excel-expert.
Just exploring strange territory.

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"


Helmut Weber[_2_]

determine if wrap text is set within a range
 
Hi,

on MsgBox Selection.Cells.WrapText

error 94 occurs,

if not all cells have the same wrap property,
which could speed up checking.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"







Dave Peterson

determine if wrap text is set within a range
 
Depends on how much info you need.

If you select a range and look at format|cells|alignment tab, you'll see that
the wraptext is either:

clear (none has that setting)
checked (green check) (all have that setting)
or light check (green block) (some do, some don't).

You can check for the same thing in code:

Option Explicit
Sub testme01()
Dim myWT As Variant
Dim myRng As Range
Dim myCell As Range
Dim wks As Worksheet

Set wks = Worksheets("sheet1")

With wks
Set myRng = .Range("a1:c10")
End With

myWT = myRng.WrapText

If myWT = True Then
'all cells have that setting
MsgBox myRng.Address(0, 0) & " are all set for wrap text"
ElseIf myWT = False Then
'no cells have that setting
MsgBox myRng.Address(0, 0) & " is not set for wrap text"
Else
'mywt = null
For Each myCell In myRng.Cells
If myCell.WrapText = True Then
MsgBox myCell.Address(0, 0) & " is set for wrap text"
End If
Next myCell
End If

End Sub


dk wrote:

Thanks

So it appears that Looping through the range is the only way?

"Helmut Weber" wrote:

Hi dk

like this:

Dim oCll As Range
For Each oCll In Selection.Cells
If oCll.WrapText = True Then
MsgBox oCll.Address
End If
Next

--
Greetings from Bavaria, Germany

I'm not an Excel-expert.
Just exploring strange territory.

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"


--

Dave Peterson


All times are GMT +1. The time now is 01:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com