ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Checkbox Problem, Please Help! (https://www.excelbanter.com/excel-programming/371782-checkbox-problem-please-help.html)

Magnivy

Checkbox Problem, Please Help!
 
Hello,

A former coworker wrote a macro that creates checkboxes in each cell in
column B, starting in cell B17, based on the values of the corresponding
cells in column C. The captions for the checkboxes are equal to the values
of cells in column C. The macro stops when it reaches the first empty value
in column C. The code is pasted below.

The problem is that when I run the macro, it enters the checkboxes in column
A instead of column B. I cant figure out why this is happening. Any help
with this would be greatly appreciated.

Thank you!

Magnivy

Sub Create_Status_Checkboxes()

Dim x
Dim objRange As Excel.Range

Set objRange = Sheet7.Range("B17")

For Each x In objRange.Worksheet.Shapes
If InStr(1, x.Name, "Check Box") 0 Then x.Delete
Next

Do Until IsEmpty(objRange.Offset(0, 1))

Set x = objRange.Worksheet.CheckBoxes.Add(0, objRange.Top,
objRange.Width, objRange.Height)
objRange.Font.ColorIndex = IIf(objRange.Interior.ColorIndex < 0, 2,
objRange.Interior.ColorIndex)
objRange.value = False

With x
.Text = objRange.Offset(, 1).value
.Placement = xlMove
.PrintObject = False
.value = xlOff
.LinkedCell = objRange.AddressLocal
End With

Set objRange = objRange.Offset(1)

Loop

End Sub



Magnivy

Checkbox Problem, Please Help!
 
I figured out the problem.

Thanks for reading my question!

Magnivy

"Magnivy" wrote:

Hello,

A former coworker wrote a macro that creates checkboxes in each cell in
column B, starting in cell B17, based on the values of the corresponding
cells in column C. The captions for the checkboxes are equal to the values
of cells in column C. The macro stops when it reaches the first empty value
in column C. The code is pasted below.

The problem is that when I run the macro, it enters the checkboxes in column
A instead of column B. I cant figure out why this is happening. Any help
with this would be greatly appreciated.

Thank you!

Magnivy

Sub Create_Status_Checkboxes()

Dim x
Dim objRange As Excel.Range

Set objRange = Sheet7.Range("B17")

For Each x In objRange.Worksheet.Shapes
If InStr(1, x.Name, "Check Box") 0 Then x.Delete
Next

Do Until IsEmpty(objRange.Offset(0, 1))

Set x = objRange.Worksheet.CheckBoxes.Add(0, objRange.Top,
objRange.Width, objRange.Height)
objRange.Font.ColorIndex = IIf(objRange.Interior.ColorIndex < 0, 2,
objRange.Interior.ColorIndex)
objRange.value = False

With x
.Text = objRange.Offset(, 1).value
.Placement = xlMove
.PrintObject = False
.value = xlOff
.LinkedCell = objRange.AddressLocal
End With

Set objRange = objRange.Offset(1)

Loop

End Sub




All times are GMT +1. The time now is 10:59 PM.

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