ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   dynamically creating check boxes (https://www.excelbanter.com/excel-programming/282860-dynamically-creating-check-boxes.html)

Erin[_5_]

dynamically creating check boxes
 
I want to have a column in my spreadsheet that contains a
check box. I need to dynamically create this once the
spreadsheet is populated from the database. I am doing
this by copying a dummy one I have on a hidden sheet with
the following code:

Sub CreateCheckBoxes()
NumRows = Range("B4").CurrentRegion.Rows.Count + 4
For x = 5 To NumRows
Sheets("Input Data").Shapes("chkView").Copy
Range("J" & x).Select
ActiveSheet.Paste
Selection.Name = "chkView" & Range("A" & x).Value
Next x
End Sub

I want the check box to be in each row of the J column.
But, it doesn't place it here.
Anyone know how to force the check box to do into a
particular cell without hard-coding the position
coordinates?

Tom Ogilvy

dynamically creating check boxes
 
You say without hard code the position settings, but why not? Why struggle?

Sub CreateCheckBoxes()
NumRows = Range("B4").CurrentRegion.Rows.Count + 4
For x = 5 To NumRows
Sheets("Input Data").Shapes("chkView").Copy
Range("J" & x).Select
ActiveSheet.Paste
Selection.Name = "chkView" & Range("A" & x).Value
With Range("J" & x)
selection.Top = .Top
selection.Left = .Left
' and possibly
'selection.Height = .Height
'selection.Width = .Width
End With
Next x
End Sub

--
Regards,
Tom Ogilvy

"Erin" wrote in message
...
I want to have a column in my spreadsheet that contains a
check box. I need to dynamically create this once the
spreadsheet is populated from the database. I am doing
this by copying a dummy one I have on a hidden sheet with
the following code:

Sub CreateCheckBoxes()
NumRows = Range("B4").CurrentRegion.Rows.Count + 4
For x = 5 To NumRows
Sheets("Input Data").Shapes("chkView").Copy
Range("J" & x).Select
ActiveSheet.Paste
Selection.Name = "chkView" & Range("A" & x).Value
Next x
End Sub

I want the check box to be in each row of the J column.
But, it doesn't place it here.
Anyone know how to force the check box to do into a
particular cell without hard-coding the position
coordinates?




Erin[_5_]

dynamically creating check boxes
 
Your solution is perfect, and just what I needed to do.
And I don't consider this hard-coding at all, since it is
dynamically placed at the cell coordinates of the
appropriate cell.

THANKS!
-----Original Message-----
You say without hard code the position settings, but why

not? Why struggle?

Sub CreateCheckBoxes()
NumRows = Range("B4").CurrentRegion.Rows.Count + 4
For x = 5 To NumRows
Sheets("Input Data").Shapes("chkView").Copy
Range("J" & x).Select
ActiveSheet.Paste
Selection.Name = "chkView" & Range("A" & x).Value
With Range("J" & x)
selection.Top = .Top
selection.Left = .Left
' and possibly
'selection.Height = .Height
'selection.Width = .Width
End With
Next x
End Sub

--
Regards,
Tom Ogilvy

"Erin" wrote in

message
...
I want to have a column in my spreadsheet that contains

a
check box. I need to dynamically create this once the
spreadsheet is populated from the database. I am doing
this by copying a dummy one I have on a hidden sheet

with
the following code:

Sub CreateCheckBoxes()
NumRows = Range("B4").CurrentRegion.Rows.Count + 4
For x = 5 To NumRows
Sheets("Input Data").Shapes("chkView").Copy
Range("J" & x).Select
ActiveSheet.Paste
Selection.Name = "chkView" & Range("A" &

x).Value
Next x
End Sub

I want the check box to be in each row of the J column.
But, it doesn't place it here.
Anyone know how to force the check box to do into a
particular cell without hard-coding the position
coordinates?



.


Tom Ogilvy

dynamically creating check boxes
 
Different interpretation of hard-coding <g now is see what you were
saying.

--
Regards,
Tom Ogilvy
]
"Erin" wrote in message
...
Your solution is perfect, and just what I needed to do.
And I don't consider this hard-coding at all, since it is
dynamically placed at the cell coordinates of the
appropriate cell.

THANKS!
-----Original Message-----
You say without hard code the position settings, but why

not? Why struggle?

Sub CreateCheckBoxes()
NumRows = Range("B4").CurrentRegion.Rows.Count + 4
For x = 5 To NumRows
Sheets("Input Data").Shapes("chkView").Copy
Range("J" & x).Select
ActiveSheet.Paste
Selection.Name = "chkView" & Range("A" & x).Value
With Range("J" & x)
selection.Top = .Top
selection.Left = .Left
' and possibly
'selection.Height = .Height
'selection.Width = .Width
End With
Next x
End Sub

--
Regards,
Tom Ogilvy

"Erin" wrote in

message
...
I want to have a column in my spreadsheet that contains

a
check box. I need to dynamically create this once the
spreadsheet is populated from the database. I am doing
this by copying a dummy one I have on a hidden sheet

with
the following code:

Sub CreateCheckBoxes()
NumRows = Range("B4").CurrentRegion.Rows.Count + 4
For x = 5 To NumRows
Sheets("Input Data").Shapes("chkView").Copy
Range("J" & x).Select
ActiveSheet.Paste
Selection.Name = "chkView" & Range("A" &

x).Value
Next x
End Sub

I want the check box to be in each row of the J column.
But, it doesn't place it here.
Anyone know how to force the check box to do into a
particular cell without hard-coding the position
coordinates?



.





All times are GMT +1. The time now is 05:32 PM.

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