PDA

View Full Version : Solved: Creating a textbox in each cell of the active row range Column 1 to 24



frank_m
04-19-2011, 12:46 PM
SOLVED -->Duh :rotlaugh: iLeft = 0 should be iLeft = cll.Left
for some reason I often need to post here before I can spot a bug.

Thanks
----------------------------------------------------------------

Hi,

I'm trying to create a text box in each cell of the current row from column 1 to 24, (as a row indicator with cell specific macro assigned based on the cells address)--->but my code is only creating a text box in Column 1

I should be able to figure this out, but am stumbling. :banghead:

Thanks in advance for some help.
Sub Macro1()

Dim cll As Range

Dim iLeft As Integer, iTop As Integer, iWidth As Integer, iHeight As Integer
Dim shp As Shape
Dim TheRow As Range

ActiveSheet.TextBoxes.Delete

Set TheRow = ActiveCell.EntireRow.Resize(, 24)

If Not TheRow Is Nothing Then
For Each cll In TheRow.Cells

iLeft = 0' found the bug here (should be iLeft = cll.Left)
iTop = cll.Top + cll.Height - 1
iWidth = cll.Width
iHeight = 0.75

Set shp = ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, _
iLeft, iTop, iWidth, iHeight)

With shp
.Name = cll.Address
.Line.ForeColor.SchemeColor = 10
.OnAction = "MacroColumn" & cll.Column
End With

Next cll
End If

End Sub