添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Hi, I have this code that is supposed to find all cells at maximum row height, insert row below, merge cells, then expand so all text is visible.  Sometimes it runs all the way through but only expands the first merged cell, not all that it finds.  Sometimes I get a type mismatch error.  Can someone tell me where I made the error.  I have no experience in excel vba programming.  What I'd really like is to search for row height about 400 and add row below, merge and expand.  I think that will capture everything since character count will vary based on font size.

'Refer to all cells
Worksheets("Group").Range("A1").Select
Set Where = Range("A1").CurrentRegion

'From bottom to top
For i = Where.Rows.Count To 1 Step -1
'Refer to the row
maxLen = 0
insrt = False
Set Here = Where.Rows(i)
For Each This In Here.Cells
If (Len(This.Value) > maxLen) Then This is where the mismatch is occurring.
maxLen = Len(This.Value)
End If
If (Len(This.Value)) > allowedLength Then
insrt = True
End If
If insrt Then
Here.Offset(1).EntireRow.Insert
For Each This In Here.Cells
This.Resize(2).Merge
newHeight = (maxLen - allowedLength) / 4
Rows(Here.Row).RowHeight = maxHeight
Rows(Here.Offset(1).Row).RowHeight = newHeight
Rows(Here.Row).AutoFit
End If

I've been picking up bits and pieces from other users.

Thanks,

Cindy

Harassment is any behavior intended to disturb or upset a person or group of people. Threats include any threat of suicide, violence, or harm to another. Any content of an adult theme or inappropriate to a community web site. Any image, link, or discussion of nudity. Any behavior that is insulting, rude, vulgar, desecrating, or showing disrespect. Any behavior that appears to violate End user license agreements, including providing product keys or links to pirated software. Unsolicited bulk mail or bulk advertising. Any link to or advocacy of virus, spyware, malware, or phishing sites. Any other inappropriate content or behavior as defined by the Terms of Use or Code of Conduct. Any image, link, or discussion related to child pornography, child nudity, or other child abuse or exploitation. Harassment is any behavior intended to disturb or upset a person or group of people. Threats include any threat of suicide, violence, or harm to another. Any content of an adult theme or inappropriate to a community web site. Any image, link, or discussion of nudity. Any behavior that is insulting, rude, vulgar, desecrating, or showing disrespect. Any behavior that appears to violate End user license agreements, including providing product keys or links to pirated software. Unsolicited bulk mail or bulk advertising. Any link to or advocacy of virus, spyware, malware, or phishing sites. Any other inappropriate content or behavior as defined by the Terms of Use or Code of Conduct. Any image, link, or discussion related to child pornography, child nudity, or other child abuse or exploitation.