M
Mark
Running VB code to add comments to a range of cells.
The resulting comments look like this (all on one wrapped line):
"Hatters Pond Field Mobile, AL".
I'd rather the comment was on two lines:
"Hatters Pond Field
Mobile, AL"
If I was typing the comment manually, I'd add a carriage return to get
the comments on two lines. However, I'm running the code below. Any
suggestions?
Thanks, Mark
Private Sub CommandButton2_Click()
Dim sh1 As Worksheet
Dim sh2 As Worksheet
Set sh1 = Worksheets("MB BUYERS")
Set sh2 = Worksheets("PROJ")
Dim cell As Range
For Each cell In sh1.Range("B6:B54")
On Error Resume Next
cell.Comment.Delete
On Error GoTo 0
cell.AddComment Text:=sh2.Cells(cell.Row - 4, 5) & _
" " & sh2.Cells(cell.Row - 4, 6)
cell.Select
ActiveCell.Comment.Visible = True
cell.Comment.Shape.Select True
Selection.ShapeRange.ScaleHeight 2#, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 1.22, msoFalse,
msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 0.7, msoFalse,
msoScaleFromTopLeft
cell.Select
ActiveCell.Comment.Visible = False
Next
End Sub
The resulting comments look like this (all on one wrapped line):
"Hatters Pond Field Mobile, AL".
I'd rather the comment was on two lines:
"Hatters Pond Field
Mobile, AL"
If I was typing the comment manually, I'd add a carriage return to get
the comments on two lines. However, I'm running the code below. Any
suggestions?
Thanks, Mark
Private Sub CommandButton2_Click()
Dim sh1 As Worksheet
Dim sh2 As Worksheet
Set sh1 = Worksheets("MB BUYERS")
Set sh2 = Worksheets("PROJ")
Dim cell As Range
For Each cell In sh1.Range("B6:B54")
On Error Resume Next
cell.Comment.Delete
On Error GoTo 0
cell.AddComment Text:=sh2.Cells(cell.Row - 4, 5) & _
" " & sh2.Cells(cell.Row - 4, 6)
cell.Select
ActiveCell.Comment.Visible = True
cell.Comment.Shape.Select True
Selection.ShapeRange.ScaleHeight 2#, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 1.22, msoFalse,
msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 0.7, msoFalse,
msoScaleFromTopLeft
cell.Select
ActiveCell.Comment.Visible = False
Next
End Sub